Subject: | _perl_abs_path oddly returns empty string on failure |
Date: | Thu, 9 Jul 2009 13:53:18 -0700 |
To: | bug-PathTools [...] rt.cpan.org |
From: | Randall Lucas <rlucas [...] rlucas.net> |
In Cwd.pm 3.2701, line 501, _perl_abs_path(), there are a couple of
execution paths that could lead to a
return '';
Specifically, if you can't stat the $start path, it carps and returns '';
unless (@cst = stat( $start ))
{
_carp("stat($start): $!");
return '';
}
I can't see that the correct behavior is specified anywhere, but there are
several other places that suggest that it should die or croak instead of
returning empty. For example, in fast_abs_path, failure to -e $path gets a
croak.
unless (-e $path) {
_croak("$path: No such file or directory");
}
The reason I bring this up is that it appears that File::pushd 1.00 relies
upon an eval {}; to check for the success of abs_path. On Mac OS X,
abs_path ends up using the _perl_abs_path version, and returns '' without
dying for a bogus directory.
I am also reporting this for File::pushd, but it may be worth standardizing
the behavior in Cwd so that failure dies or croaks.
Mac OS X 10.5.7 (9J61)
perl, v5.8.8 built for darwin-thread-multi-2level
Cwd.pm 3.2701