Bug#618524: perl: abs_path is broken

Dominic Hargreaves dom at earth.li
Wed Mar 16 15:34:21 UTC 2011


severity 618524 minor
thanks

On Wed, Mar 16, 2011 at 01:15:31AM +0200, Krasu wrote:

> Sample code:
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> use Cwd;
> use Cwd 'abs_path';
> 
> my $path = $ARGV[0];
> my $r = abs_path($path);
> print "$r\n";
> 
> Test:
> 
> # ./test.pl /usr/lib/ololo
> /usr/lib/ololo
> 
> # ./test.pl /usr/lib/ololo/
> Use of uninitialized value $r in concatenation (.) or string at ./1.pl line 10.
> 
> # ./test.pl /usr/lib/ololo/1
> Use of uninitialized value $r in concatenation (.) or string at ./1.pl line 10.

Using your example script:

$ ./618524 /tmp
/tmp
$ ./618524 /tmp/
/tmp
$ ./618524 /tmp/foo
/tmp/foo
$ ./618524 /tmp/foo/
Use of uninitialized value $r in concatenation (.) or string at ./618524 line 10.

In other words, undef is returned if a path including a non-existent
directory followed by further components is included. The behaviour of
the function is not well-defined in this case by the document, so this
is at worst a documentation bug. Downgrading severity accordingly.

Dominic.

-- 
Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)






More information about the Perl-maintainers mailing list