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

RE: MM_Win32.t failures (caused by PathTools upgrade)

Thread Previous | Thread Next
From:
Steve Hay
Date:
January 31, 2008 09:31
Subject:
RE: MM_Win32.t failures (caused by PathTools upgrade)
Message ID:
1B32FF956ABF414C9BCE5E487A1497E70132BA68@ukmail02.planit.group
Michael G Schwern wrote:
> Steve Hay wrote:
>> In short, this program:
>> 
>> use File::Spec::Functions qw(catdir);
>> my @path_eg = qw( c: trick dir/now_OK );
>> print catdir(@path_eg);
>> 
>> used to output:
>> 
>> C:\trick\dir\now_OK
>> 
>> but now outputs:
>> 
>> C:trick\dir\now_OK
>> 
> 
> MakeMaker runs catfile() through canonpath() to work around some old
> bugs. It's possible that canonpath() is the one translating
> C:trick\dir\now_OK into C:\trick\dir\now_OK.  If so, that's a bug.
> 
> Can you check what File::Spec->canonpath("C:trick\dir\now_OK") does?

Ick. You didn't mean that: you meant check what
File::Spec->canonpath('C:trick\dir\now_OK') does, and the answer is
nothing:

C:\p5p\bleadperl>.\perl -MFile::Spec -e "print
File::Spec->canonpath('C:trick\dir\now_OK')"
C:trick\dir\now_OK


> 
> 
>> Either output is arguably correct (the notation "C:path" means the
>> file or directory called "path" relative to the current directory on
>> the "C:" drive, there being the notion of a current directory per
>> drive), and the File::Spec docs don't make it clear which output is
>> to be expected. 
>> 
>> I can imagine that most people would expect catdir(qw(C: trick)) to
>> produce "C:\trick". It currently doesn't, and it isn't clear what you
>> have to do to get "C:\trick":
> 
> Probably use a blank directory to represent root.  That's what Unix
> does.  Try: 
> 
> catdir( 'c:', '', 'trick', 'dir' );

No good either:

C:\p5p\bleadperl>.\perl -MFile::Spec -e "print File::Spec->catdir('C:',
'', 'trick', 'dir')"
C:trick\dir


> 
> Actually the correct answer is "none of the above" because catdir()
> uses directories, not volumes.  In reality the correct thing to use
> is catpath(). 

It's still confusing:

C:\p5p\bleadperl>.\perl -MFile::Spec -e "print File::Spec->catpath('C:',
'trick', 'file')"
C:trick\file

C:\p5p\bleadperl>.\perl -MFile::Spec -e "print
File::Spec->catpath('C:\\', 'trick', 'file')"
C:\trick\file

In other words catpath() expects the $volume to be something like C:\
rather than just C:, which is at odds with splitpath() which returns the
$volume as just C:

C:\p5p\bleadperl>.\perl -MFile::Spec -e "print
+(File::Spec->splitpath('C:\trick\file'))[0]"
C:

(This catpath()/splitpath() confusion is not new in PathTools-3.25_01,
though.)


> 
> 
>> and neither does this:
>> 
>> my @path_eg = qw( c: / trick dir/now_OK );
>> print catdir(@path_eg);
> 
> That doesn't work?  Now that is odd.  Have you tried using backwhacks?

That definitely doesn't work with either forward- or back-slashes:

C:\p5p\bleadperl>.\perl -MFile::Spec -e "print File::Spec->catdir(qw(C:
/ trick dir/now_OK))
C:trick\dir\now_OK

C:\p5p\bleadperl>.\perl -MFile::Spec -e "print File::Spec->catdir(qw(C:
\ trick dir\now_OK))
C:trick\dir\now_OK

Thread Previous | Thread Next


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