develooper Front page | perl.perl5.porters | Postings from May 2013

[perl #117423] Cwd::abs_path returns undef for non-existent paths

Thread Previous
James E Keenan via RT
May 9, 2013 02:05
[perl #117423] Cwd::abs_path returns undef for non-existent paths
Message ID:
On Sun Mar 31 15:05:56 2013, dom wrote:
> This is a bug report for perl from,
> generated with the help of perlbug 1.39 running under perl 5.17.10.
> -----------------------------------------------------------------
> [Please describe your issue here]
> As reported in
> <>
> the behaviour of Cwd::abs_path has changed over time to working with
> non-existent to paths, to not.
> Quoting Roger in that report (on Sun, 11 Jul 2010):
> "To justify why I think this is a serious misfeature, let's look at
> what we want to do.  abs_path is doing two things:
> 1) if the path is relative to the CWD, we make it absolute
> 2) if the path contains any symbolic links, we remove them
> Now, if the path doesn't yet exist, by definition it doesn't
> contain any links, so part 2 can be skipped.  But making it
> absolute is still useful.  The path may also partially exist.
> If I'm in /tmp/foo and call abs_path('bar') then it could
> return /tmp/foo/bar if /tmp/foo contains no links.  If foo
> was a symlink to /srv/baz then it should return /srv/baz/bar.
> To summarise: abs_path can still work sanely in the existence
> of a nonexistent (or partially existent) path.  It can walk up
> the tree so far as it can (while it exists) both making it
> absolute and removing links as necessary and then it can
> return the nonexistent part verbatim after that.  For users
> who want to get a canonicalised path, returning undef when
> there's a perfectly reasonable answer to give them is not
> good, and it would be great to get this long-standing
> regression fixed.
> "

I observe the following on Darwin (where /tmp is a symlink to /private/tmp):

$ cd /tmp
$ perl -E 'use Cwd; say "<", Cwd::abs_path(q{foo}), ">"'

$ perl -E 'use Cwd; say "<", Cwd::abs_path(q{foo/bar}), ">"'

... where neither 'foo' nor 'foo/bar' exists.  It seems it is the
addition of another level in the filesystem that causes 'abs_path' to
return what I think is more likely an empty string rather than an
undefined value.


Thank you very much.
Jim Keenan

via perlbug:  queue: perl5 status: new

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About