Bug#257568: Cwd::abs_path returns undef for non-existent packages

Roger Leigh rleigh at debian.org
Sun Jul 11 21:06:23 UTC 2010


found 257568 5.10.1-13
thanks

On Mon, Jul 05, 2004 at 08:10:22PM +0200, David Kimdon wrote:
> It looks to me like the function is behaving as documented (see 
> Cwd(3perl)).  If the path does not exist there is no way for the
> function to succeed since the function is defined to resolve symbolic
> links.  For example:
> 
> $ pwd
> /tmp
> $ mkdir -p dir
> $ ln -s dir link
> $ perl -e 'use Cwd; print Cwd::abs_path("link")
> /tmp/dir
> 
> If link did not exist the function could not know to return '/tmp/dir'

In this case, the correct return value would surely be '/tmp/link'.
In this situation '/tmp/dir' would be plain wrong.  Since link doesn't
exists, it's by definition absolute if we are just about to create it.

> What behavior are you looking for?  I don't see a bug here.  I dropped
> the severity to wishlist since it looks to me like you would like a
> function that does something for you, but I am not sure what.  Are you
> looking for something to concatenate Cwd::abs_path(".") with a
> relative path?

I've got bitten by this (IMO serious bug) in the sbuild package,
where we use it to get an absolute path to a directory which isn't
yet created.  I'm sure it's been fixed and re-introduced sometime
in the past year because it was working fine last year and I was
just notified that it had regressed.

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.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/perl-maintainers/attachments/20100711/7c59af1c/attachment.pgp>


More information about the Perl-maintainers mailing list