In IO::Spec::Unix§

See primary documentation in context for method rel2abs

method rel2abs(Str() $path$base = $*CWD --> Str:D)

Returns a string representing $path converted to absolute path, based at $base, which defaults to $*CWD. If $base is not an absolute path, it will be made absolute relative to $*CWD, unless $*CWD and $base are the same.

say $*CWD;                                  # OUTPUT: «"/home/camelia".IO␤» 
 
say IO::Spec::Unix.rel2abs: 'foo';          # OUTPUT: «/home/camelia/foo␤» 
say IO::Spec::Unix.rel2abs: './';           # OUTPUT: «/home/camelia␤» 
say IO::Spec::Unix.rel2abs: 'foo/../../';   # OUTPUT: «/home/camelia/foo/../..␤» 
say IO::Spec::Unix.rel2abs: '/foo/';        # OUTPUT: «/foo␤» 
 
say IO::Spec::Unix.rel2abs: 'foo''bar';   # OUTPUT: «/home/camelia/bar/foo␤» 
say IO::Spec::Unix.rel2abs: './''/bar';   # OUTPUT: «/bar␤» 
say IO::Spec::Unix.rel2abs: '/foo/''bar'# OUTPUT: «/foo␤» 
 
say IO::Spec::Unix.rel2abs: 'foo/../../''bar';
# OUTPUT: «/home/camelia/bar/foo/../..␤» 

In IO::Spec::Cygwin§

See primary documentation in context for method rel2abs

method rel2abs(|c --> List:D)

Same as IO::Spec::Win32.rel2abs, except replaces backslashes with slashes in the final result.

In IO::Spec::Win32§

See primary documentation in context for method rel2abs

method rel2abs(Str() $path$base = $*CWD --> Str:D)

Returns a string representing $path converted to absolute path, based at $base, which defaults to $*CWD. If $base is not an absolute path, it will be made absolute relative to $*CWD, unless $*CWD and $base are the same.

say $*CWD;                                   # OUTPUT: «"C:\Users\camelia".IO␤» 
 
say IO::Spec::Win32.rel2abs: 'foo';          # OUTPUT: «C:\Users\camelia\foo␤» 
say IO::Spec::Win32.rel2abs: './';           # OUTPUT: «C:\Users\camelia␤» 
say IO::Spec::Win32.rel2abs: 'foo/../../';   # OUTPUT: «C:\Users\camelia\foo\..\..␤» 
say IO::Spec::Win32.rel2abs: '/foo/';        # OUTPUT: «C:\foo␤» 
 
say IO::Spec::Win32.rel2abs: 'foo''bar';   # OUTPUT: «C:\Users\camelia\bar\foo␤» 
say IO::Spec::Win32.rel2abs: './''/bar';   # OUTPUT: «\bar␤» 
say IO::Spec::Win32.rel2abs: '/foo/''bar'# OUTPUT: «C:\foo␤» 
 
say IO::Spec::Win32.rel2abs: 'foo/../../''bar';
# OUTPUT: «C:\Users\camelia\bar\foo\..\..␤»