X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCwd.pm;h=5b5f21672bd66d12e5a64726724d829876857aa3;hb=0bd43963443f227c8bd1734af34fc6e6a7d2d54e;hp=0a1b2b85a7acfeed2a7ea42a135a9da8a260a654;hpb=cade0c02de13e52be76bdb1f796759b43676baa2;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Cwd.pm b/lib/Cwd.pm index 0a1b2b8..5b5f216 100644 --- a/lib/Cwd.pm +++ b/lib/Cwd.pm @@ -95,7 +95,7 @@ A synonym for abs_path(). =item fast_abs_path - my $abs_path = abs_path($file); + my $abs_path = fast_abs_path($file); A more dangerous, but potentially faster version of abs_path. @@ -188,6 +188,8 @@ $pwd_cmd ||= 'pwd'; # The 'natural and safe form' for UNIX (pwd may be setuid root) sub _backtick_pwd { my $cwd = `$pwd_cmd`; + # Belt-and-suspenders in case someone said "undef $/". + local $/ = "\n"; # `pwd` may fail e.g. if the disk is full chomp($cwd) if defined $cwd; $cwd; @@ -198,7 +200,9 @@ sub _backtick_pwd { unless(defined &cwd) { # The pwd command is not available in some chroot(2)'ed environments - if($^O eq 'MacOS' || grep { -x "$_/pwd" } split(':', $ENV{PATH})) { + if( $^O eq 'MacOS' || (defined $ENV{PATH} && + grep { -x "$_/pwd" } split(':', $ENV{PATH})) ) + { *cwd = \&_backtick_pwd; } else { @@ -437,11 +441,13 @@ sub _vms_abs_path { sub _os2_cwd { $ENV{'PWD'} = `cmd /c cd`; chop $ENV{'PWD'}; + $ENV{'PWD'} =~ s:\\:/:g ; return $ENV{'PWD'}; } sub _win32_cwd { $ENV{'PWD'} = Win32::GetCwd(); + $ENV{'PWD'} =~ s:\\:/:g ; return $ENV{'PWD'}; } @@ -454,6 +460,7 @@ sub _dos_cwd { if (!defined &Dos::GetCwd) { $ENV{'PWD'} = `command /c cd`; chop $ENV{'PWD'}; + $ENV{'PWD'} =~ s:\\:/:g ; } else { $ENV{'PWD'} = Dos::GetCwd(); } @@ -461,12 +468,18 @@ sub _dos_cwd { } sub _qnx_cwd { + local $ENV{PATH} = ''; + local $ENV{CDPATH} = ''; + local $ENV{ENV} = ''; $ENV{'PWD'} = `/usr/bin/fullpath -t`; chop $ENV{'PWD'}; return $ENV{'PWD'}; } sub _qnx_abs_path { + local $ENV{PATH} = ''; + local $ENV{CDPATH} = ''; + local $ENV{ENV} = ''; my $path = @_ ? shift : '.'; my $realpath=`/usr/bin/fullpath -t $path`; chop $realpath;