On the VMS version of splitdir, splitting a relative path gives you
an empty directory at the beginning of the returned array:

$ perl -"MFile::Spec" -e "print join qq/\n/, File::Spec::VMS->splitdir('[.foo.bar.baz]');"

foo
bar
baz

For an absolute path, we get the volume name glued to the first directory:

$ perl -"MFile::Spec" -e "print join qq/\n/, File::Spec::VMS->splitdir('dev1:[foo.bar.baz]');"
dev1:[foo
bar
baz

The latter is not necessarily wrong, considering that we really
should have called splitpath rather than splitdir if we knew it was
an absolute spec.  The former does seem wrong, and is an accident of
the fact that dot is the directory delimiter and so the first element
of '.foo.bar.baz' when split on dots has zero length.

The Unix version of splitdir has almost the reverse behavior.  We get
a leading empty element with an absolute path but not with a relative
path:

$ perl -"MFile::Spec" -e "print join qq/\n/, File::Spec::Unix->splitdir('foo/bar/baz');"
foo
bar
baz
$ perl -"MFile::Spec" -e "print join qq/\n/, File::Spec::Unix->splitdir('/foo/bar/baz');"

foo
bar
baz

or a relative  path with './' at the beginning:

$ perl -"MFile::Spec" -e "print join qq/\n/, File::Spec::Unix->splitdir('./foo/bar/baz');"
.
foo
bar
baz


The test suite enforces the current behavior on VMS, but I'm not sure
it should stay the way it is.  I'm pretty sure what ought to happen
is that for relative paths:

join qq/\n/, splitdir('[.foo.bar.baz]')

should give me:
foo
bar
baz

just like it does on other platforms.  catdir('','foo','bar','baz')
already gives the same result as catdir('foo','bar','baz'), so this
would not be a problem for round-trip scenarios.

The absolute case has no exact parallel on Unix.  I think the current
behavior arises from blindly splitting on what is a directory
delimiter, and what ought to happen instead is that we should treat
the device name like the leading '/' on a Unix absolute spec.  So

join qq/\n/, splitdir('dev1:[foo.bar.baz]')

would give me:
dev1:
foo
bar
baz

We can already put Humpty Dumpty back together again with catdir:

$ perl -"MFile::Spec" -e "print File::Spec::VMS->catdir('dev1:','foo','bar','baz');"
dev1:[foo.bar.baz]

So it seems that instead of a device name glued to the first
directory, we ought to treat the  device name as a separate
"directory."

This is more of a larvae report than a bug report; I'm trying to
think of things that might break if we change current behavior, but
I'm also banging my head against the wall because of the way it works
now.  Several things in Module::Build trip over the current behavior,
and one big thing in Module::Pluggable did until I hacked around it.

Anyone who has thoughts about how this ought to work, or concerns
about what might stop working if we change things, please comment.

--
________________________________________
Craig A. Berry
mailto:[EMAIL PROTECTED]

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

Reply via email to