develooper Front page | perl.perl5.porters | Postings from June 2008

Re: Cwd::abs_path behavior with non-existant paths

Thread Previous
From:
John E. Malmberg
Date:
June 12, 2008 20:36
Subject:
Re: Cwd::abs_path behavior with non-existant paths
Message ID:
4851EB3F.80708@qsl.net
Ben Morrow wrote:
> Quoth wb8tyw@qsl.net ("John E. Malmberg"):
>> Before the 5.10 release, we were working on implementing an interface to 
>> realpath() on VMS.
>>
>> We discovered that the VMS behavior for non-existant paths was different 
>> than on other platforms.
>>
>> To get a fair sampling, could this test be run on a number of different 
>> platforms to see what the consensus on the proper behavior should be.
>>
>> perl -mCwd -e "print Cwd::abs_path('foo/non-existant.file')"
>>
>> perl -mCwd -e "print Cwd::abs_path('/foo/non-existant.file')"
>>
>> perl -mCwd -e "print Cwd::abs_path('non-existant.file')"
> 
> ~% perl -v
> 
> This is perl, v5.8.8 built for i386-freebsd-64int
> [...]
> ~% perl -mCwd -le"print Cwd::abs_path('/foo/non-existant.file')" 
> 
> ~% perl -mCwd -le"print Cwd::abs_path('foo/non-existant.file')" 
> 
> ~% perl -mCwd -le"print Cwd::abs_path('non-existant.file')" 
> /home/mauzo/non-existant.file
> ~% perl -mCwd -le"print Cwd::_perl_abs_path('/foo/non-existant.file')"
> stat(/foo/non-existant.file): No such file or directory at -e line 1

I mis-copied one example:

  perl -mCwd -le "print Cwd::abs_path('/non-existant.file')"
/non-existant.file

So it looks like if a directory is not present, it is expected to return 
the original filename.

So I get the same results on Perl 5.8.5 on Centos 4.2 as you get on BSD.

C:\>perl -v

This is perl, v5.10.0 built for MSWin32-x86-multi-thread

Activestate Perl on WinXP gives different results:

C:\>perl -mCwd -le "print Cwd::abs_path('/foo/non-existant.file')"
/foo/non-existant.file: No such file or directory at -e line 1

C:\>perl -mCwd -le "print Cwd::abs_path('foo/non-existant.file')"
foo/non-existant.file: No such file or directory at -e line 1

C:\>perl -mCwd -le "print Cwd::abs_path('/non-existant.file')"
/non-existant.file: No such file or directory at -e line 1

C:\>perl -mCwd -le "print Cwd::abs_path('non-existant.file')"
non-existant.file: No such file or directory at -e line 1

$ perl -v

This is perl, v5.10.0 built for i686-cygwin-thread-multi-64int

Repeating with the above gives the same result as in ActiveState.

So the results so far are not consistent on different platforms.

Thanks,
-John

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About