Skip to content

Commit

Permalink
Merge e725e6c into 7ad5408
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed May 25, 2021
2 parents 7ad5408 + e725e6c commit f82468c
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions dist/PathTools/Cwd.pm
Expand Up @@ -181,12 +181,6 @@ if ($^O =~ /android/) {
}

my $found_pwd_cmd = defined($pwd_cmd);
unless ($pwd_cmd) {
# Isn't this wrong? _backtick_pwd() will fail if someone has
# pwd in their path but it is not /bin/pwd or /usr/bin/pwd?
# See [perl #16774]. --jhi
$pwd_cmd = 'pwd';
}

# Lazy-load Carp
sub _carp { require Carp; Carp::carp(@_) }
Expand All @@ -213,26 +207,13 @@ sub _backtick_pwd {
# we take care not to override an existing definition for cwd().

unless ($METHOD_MAP{$^O}{cwd} or defined &cwd) {
# The pwd command is not available in some chroot(2)'ed environments
my $sep = $Config::Config{path_sep} || ':';
my $os = $^O; # Protect $^O from tainting


# Try again to find a pwd, this time searching the whole PATH.
if (defined $ENV{PATH} and $os ne 'MSWin32') { # no pwd on Windows
my @candidates = split($sep, $ENV{PATH});
while (!$found_pwd_cmd and @candidates) {
my $candidate = shift @candidates;
$found_pwd_cmd = 1 if -x "$candidate/pwd";
}
}

if( $found_pwd_cmd )
{
*cwd = \&_backtick_pwd;
}
else {
*cwd = \&getcwd;
# getcwd() might have an empty prototype
*cwd = sub { getcwd(); };
}
}

Expand Down

0 comments on commit f82468c

Please sign in to comment.