Mailing List Archive

bug(s) in Cwd.pm
In Cwd.pm,
getcwd() produces a spurious warning (under -w) and returns '' for '/'

% cd /
% perl5 -we 'use Cwd; print getcwd(), "\n"'
Use of uninitialized value at /usr/local/lib/perl5/Cwd.pm line 27.

% pwd
/
%

Robin Barker

Patch:
*** /home/rmb/lib/perl/Cwd.pm Thu Sep 7 10:38:12 1995
--- /usr/local/lib/perl5/Cwd.pm Fri Oct 21 14:20:01 1994
***************
*** 13,19 ****

sub getcwd
{
! my($dotdots, $cwd, @pst, @cst, $dir, @tst) = ''; # suppress warning

unless (@cst = stat('.'))
{
--- 13,19 ----

sub getcwd
{
! my($dotdots, $cwd, @pst, @cst, $dir, @tst);

unless (@cst = stat('.'))
{
***************
*** 65,71 ****
closedir(PARENT);
} while ($dir);
chop($cwd);
! $cwd || '/'; # return '/' not ''
}


--- 65,71 ----
closedir(PARENT);
} while ($dir);
chop($cwd);
! $cwd;
}