X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/a0d0e21ea6ea90a22318550944fe6cb09ae10cda..b76b0bf9b926e6a5504a59a935a232eb91d44437:/lib/pwd.pl diff --git a/lib/pwd.pl b/lib/pwd.pl index 0cc3d4e..bd8123b 100644 --- a/lib/pwd.pl +++ b/lib/pwd.pl @@ -1,5 +1,18 @@ +warn "Legacy library @{[(caller(0))[6]]} will be removed from the Perl core distribution in the next major release. Please install it from the CPAN distribution Perl4::CoreLibs. It is being used at @{[(caller)[1]]}, line @{[(caller)[2]]}.\n"; + ;# pwd.pl - keeps track of current working directory in PWD environment var ;# +# +# This library is no longer being maintained, and is included for backward +# compatibility with Perl 4 programs which may require it. +# This legacy library is deprecated and will be removed in a future +# release of perl. +# +# In particular, this should not be used as an example of modern Perl +# programming techniques. +# +# Suggested alternative: Cwd + ;# $RCSfile: pwd.pl,v $$Revision: 4.1 $$Date: 92/08/07 18:24:11 $ ;# ;# $Log: pwd.pl,v $ @@ -16,7 +29,7 @@ sub main'initpwd { if ($ENV{'PWD'}) { local($dd,$di) = stat('.'); local($pd,$pi) = stat($ENV{'PWD'}); - if ($di != $pi || $dd != $pd) { + if (!defined $dd or !defined $pd or $di != $pi or $dd != $pd) { chop($ENV{'PWD'} = `pwd`); } } @@ -26,7 +39,7 @@ sub main'initpwd { if ($ENV{'PWD'} =~ m|(/[^/]+(/[^/]+/[^/]+))(.*)|) { local($pd,$pi) = stat($2); local($dd,$di) = stat($1); - if ($di == $pi && $dd == $pd) { + if (defined $pd and defined $dd and $di == $pi and $dd == $pd) { $ENV{'PWD'}="$2$3"; } } @@ -34,6 +47,7 @@ sub main'initpwd { sub main'chdir { local($newdir) = shift; + $newdir =~ s|/{2,}|/|g; if (chdir $newdir) { if ($newdir =~ m#^/#) { $ENV{'PWD'} = $newdir;