Subject: | File::Spec->catdir('/', ...) bug on Cygwin |
Hi,
I've discovered the following bug on Cygwin (and, telling from the code,
it occurs on QNX as well):
If catdir() is invoked with '/' as its first argument, it will return
a path name beginning with a double slash (e.g., File::Spec->catdir('/',
'usr/bin') returns '//usr/bin'), which Cygwin will interpret as a
network path.
The following patch to File/Spec/Unix.pm should correct this:
--- Unix.pm.orig 2004-02-04 22:04:22.000000000 +0100
+++ Unix.pm 2004-02-05 18:08:30.000000000 +0100
@@ -70,7 +70,13 @@
sub catdir {
my $self = shift;
- $self->canonpath(join('/', @_, '')); # '' because need a trailing '/'
+ # Avoid creating an artificial leading double slash when concatenating
+ # the arguments, because it has a special meaning on some platforms
+ # and therefore won't be collapsed by canonpath().
+ my $first = shift;
+ $first = '' if $first eq '/';
+
+ $self->canonpath(join('/', $first, @_, '')); # '' because need trailing '/'
}
=item catfile