Skip Menu |

This queue is for tickets about the File-ShareDir CPAN distribution.

Report information
The Basics
Id: 84914
Status: resolved
Priority: 0/
Queue: File-ShareDir

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
lxp [...] cpan.org
tokuhirom+cpan [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 1.03
  • 1.101
  • 1.102
Fixed in: (no value)



Subject: avoid warnings at -w mode
File::ShareDir cause some warnings. Because, - dist_dir_new returns undef if a module uses legacy path - if user uses -w, File::Spec shouts a lot of warnings :( === lib/File/ShareDir.pm ================================================================== --- lib/File/ShareDir.pm (revision 28048) +++ lib/File/ShareDir.pm (local) @@ -322,6 +322,7 @@ # If it exists, what should the path be my $dir = _dist_dir_new( $dist ); + return undef unless defined $dir; my $path = File::Spec->catfile( $dir, $file ); # Does the file exist
+1 to this patch. This warning made me write such a nasty patch like this to shut up warnings: http://coderepos.org/share/changeset/30013
Subject: _dist_file_new assumes _dist_dir_new returns a defined value
When _dist_dir_new returns undef, _dist_file_new blindly passes that undef to File::Spec->catfile. The docs for "catfile" in File::Spec don't explicitly define what should occur in such a case, but on Unix at least, undef is treated as "" which leads to _dist_file_new looking for a file in the root directory. All well and good if the root directory doesn't actually contain a file with the same name as the desired one. If it does, however: File '/vmlinuz', no read permissions at ... line ... . A contrived example, but having a share-dir file named "vmlinuz" is perfectly legitimate! Given no explicitly defined behaviour on File::Spec's part for undefined values, it seems that File::ShareDir should be ensuring that it doesn't pass such values to it, particularly since File::ShareDir in the future may croak or something when it encounters undef ([rt.cpan.org #82754]). A patch correcting this behaviour is attached.
Subject: 0001-dont-pass-undef-to-File-Spec-catfile.patch
Index: lib/File/ShareDir.pm =================================================================== --- lib/File/ShareDir.pm (revision 15773) +++ lib/File/ShareDir.pm (working copy) @@ -323,7 +323,8 @@ my $file = shift; # If it exists, what should the path be - my $dir = _dist_dir_new( $dist ); + my $dir = _dist_dir_new( $dist ); + return undef unless defined $dir; my $path = File::Spec->catfile( $dir, $file ); # Does the file exist
On Mon Apr 29 18:28:12 2013, LXP wrote: Show quoted text
> Given no explicitly defined behaviour on File::Spec's part for undefined > values, it seems that File::ShareDir should be ensuring that it doesn't > pass such values to it, particularly since File::ShareDir in the future > may croak or something when it encounters undef ([rt.cpan.org #82754]).
Oops, wrong ticket. See [rt.cpan.org #84915] instead.
Seems to be fixed in 1.110