|Subject:||inconsistent behaviour for missing path|
|X-Mailer:||MIME-tools 5.504 (Entity 5.504)|
|Message-ID:||<rt-4.0.18-9607-1408724165-1214.0-0-0 [...] rt.cpan.org>|
On linux (ubuntu 14.04 perl v5.18.2 Cwd 3.40): $ perl -e "use Cwd qw(abs_path); use Data::Dumper; print Dumper abs_path('/i/see/no/path/here');" $VAR1 = undef; On win32 (win 7 pro x64, ActiveState perl v5.16.3 Cwd 3.47 (installed via CPAN)): Show quoted text
>perl -e "use Cwd qw(abs_path); use Data::Dumper; print Dumper abs_path('/i/see/no/path/here');"/i/see/no/path/here: No such file or directory at -e line 1. In theory, for all platforms, abs_path on a missing file should return one of: a) undef b) an exception c) the pathname if it did exist ie. the same as File::Spec::Functions::rel2abs($path,getcwd()) hmm... on the above linux box: $ mkdir /tmp/foo $ cd /tmp/foo $ rmdir /tmp/foo $ perl -e "use Cwd; use Data::Dumper; print Dumper getcwd();" $VAR1 = undef; $ perl -e "use Cwd; use Data::Dumper; print Dumper cwd();" /bin/pwd: couldn't find directory entry in ‘..’ with matching i-node $VAR1 = ''; My preference would be for returning undef in all cases when the candidate path doesn't exist; though knowing the value of the absolute path that would result from creating the candidate file is useful too. I've been looking at this mostly because App::perlmv doesn't build on windows, as far as I can tell, partially because of the difference in behaviour of abs_path between platforms.