Peter (Stig) Edwards wrote:
Content of
    http://rt.cpan.org//Ticket/Display.html?id=29513
below:


Hello and thanks for maintaining PathTools.

The question/bug I have is:
"What should File::Spec->canonpath() return?"

On VMS (PathTools 3.17 and 3.25) I get undef:

perl -e "use strict;use warnings;use File::Spec;print defined
File::Spec->canonpath() ? 'def' : 'undef';"
undef

On UNIX (PathTools 3.23) I get empty string:

perl -e "use strict;use warnings;use File::Spec;print defined
File::Spec->canonpath() ? 'def' : 'undef';"
def

I would expect C<canonpath(undef)> to behave the same for both.

There is a problem on VMS if File::Spec->canonpath(undef) returns '', as VMS will treat '' 'as SYS$DISK:[].;' which is likely to cause hard to detect problems, while an undef return is likely to cause a noticeable problem.


I think this is because of the return from canonpath,
UNIX:
return "$node$path";
VMS:
return $path;

I patched version 3.25 on VMS to return "$path" and it passes all it's
tests*.

Watch out that it may leave '[].;' behind, and that will cause problems with the tests for other modules.

Thanks for your thoughts on this. I got to this point from installing
DBI 1.59 on VMS, and it calling catdir() with files as arguments and
this causing warnings from the undefined value being returned from
canonpath, example:

perl -we "use strict;use File::Spec;print
File::Spec->catdir('a','valid_dir_name');"

[.a.valid_dir_name]


perl -we "use strict;use File::Spec;print
File::Spec->catdir('a','file_not_a_dir.txt');"

If the DECC$EFS_CHARSET feature is enabled then it should return '[a.file_not_a_dir^.txt]' to be consistent with what the VMS C library should return.

If the DECC$EFS_CHARSET feature is not enabled, to be consistent with the behavior of the rest of Perl, it should return '[a.file_not_a_dir_txt]'.

The above is true only if the DECC$FILENAME_REPORT_UNIX is not enabled.

If the DECC$FILENAME_REPORT_UNIX feature is enabled, then it should return 'a/file_not_a_dir.txt' if the DECC$EFS_CHARSET is enabled, and 'a/file_not_a_dir_txt' if it the DECC$EFS_CHARSET is not enabled.

The problem right now is that File::Spec does not have an API to read the DECC$* settings.

In many cases they can be obtained by reading $ENV{DECC$EFS_CHARSET}, however in the future when an API is availble to set/get the features, the $ENV method may not be accurate.


catdir should not be called with a filename as an argument. The code should use catfile. This will also make it so that you do not need a fix to canonpath, so it does not matter what the correct behavior should be. canonpath should be fixed, and the desired behavior in this case may need to be documented, especially if it converts an undef value into a def value.

-John
[EMAIL PROTECTED]
Personal Opinion Only

Reply via email to