X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCwd.pm;h=840e2a6078431a18cee671306bc816c2f257f8d2;hb=400728b860602b352de8071deef81019cfa0d73e;hp=dbeae69eb5236eb8301bf8437317034a8d16fa3a;hpb=ed79a026b5aec9cc3f786c2971aa15a4b21f396c;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Cwd.pm b/lib/Cwd.pm index dbeae69..840e2a6 100644 --- a/lib/Cwd.pm +++ b/lib/Cwd.pm @@ -89,7 +89,15 @@ sub _backtick_pwd { # Since some ports may predefine cwd internally (e.g., NT) # we take care not to override an existing definition for cwd(). -*cwd = \&_backtick_pwd unless defined &cwd; +unless(defined &cwd) { + # The pwd command is not available in some chroot(2)'ed environments + if(grep { -x "$_/pwd" } split(':', $ENV{PATH})) { + *cwd = \&_backtick_pwd; + } + else { + *cwd = \&getcwd; + } +} # By Brandon S. Allbery @@ -180,7 +188,7 @@ sub chdir_init { } sub chdir { - my $newdir = @? ? shift : ''; # allow for no arg (chdir to HOME dir) + my $newdir = @_ ? shift : ''; # allow for no arg (chdir to HOME dir) $newdir =~ s|///*|/|g unless $^O eq 'MSWin32'; chdir_init() unless $chdir_init; return 0 unless CORE::chdir $newdir; @@ -400,7 +408,8 @@ sub _epoc_cwd { *abs_path = \&fast_abs_path; } elsif ($^O eq 'epoc') { - *getcwd = \&_epoc_cwd; + *cwd = \&_epoc_cwd; + *getcwd = \&_epoc_cwd; *fastgetcwd = \&_epoc_cwd; *fastcwd = \&_epoc_cwd; *abs_path = \&fast_abs_path;