Skip to content

Commit

Permalink
pwd: print error for getcwd() failure (#573)
Browse files Browse the repository at this point in the history
* "perldoc Cwd" explains that getcwd() can return undef on error, so handle this instead of printing "\n"
  • Loading branch information
mknos committed Apr 22, 2024
1 parent d17f62d commit f93b431
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bin/pwd
Expand Up @@ -37,11 +37,14 @@ else
die "Usage: pwd [-L|-P]\n";
}

# Account for / and \ on Win32 and non-Win32 systems
($^O=~/Win32/) ? ($dir) =~s/\//\\/g : ($dir);

unless (defined $dir) {
warn "pwd: $!\n";
exit 1;
}
if ($^O =~ m/Win32/) {
$dir =~ tr/\//\\/;
}
print $dir . "\n";

exit;

__END__
Expand Down

0 comments on commit f93b431

Please sign in to comment.