New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File::Basename basename() bug #8006
Comments
From jens.luedicke@gmail.comThere is a bug in basename() (Module File::Basename): According to the manpage: basename The basename() routine returns the first element of the list The bug: basename() doesn't return '/' for parameter '/' -- |
From @steve-m-hay
I was about to reply that as of change 25090 this is no longer a bug However, using the Cygwin basename(1) on my Win32 system I find that: C:\p5p\bleadperl>\cygwin\bin\basename / whereas (using the current bleadperl @ change 25094) C:\p5p\bleadperl>.\perl -MFile::Basename -e "print basename('/')" C:\p5p\bleadperl>.\perl -MFile::Basename -e "print basename('\\')" (blank output in both cases). Is there genuinely still a bug in File::Basename::basename(), or is it |
The RT System itself - Status changed from 'new' to 'open' |
From @schwernOn Thu, Jul 07, 2005 at 04:17:50PM -0000, Steve Hay via RT wrote:
Its a bug. Patch attached. And I found another bug, but I will keep you in suspense until my next -- |
From @schwernfb.patch--- lib/File/Basename.pm 2005/07/07 21:04:45 1.1
+++ lib/File/Basename.pm 2005/07/07 21:09:11
@@ -206,9 +206,13 @@
sub basename {
- my($name) = shift;
- _strip_trailing_sep($name);
- (fileparse($name, map("\Q$_\E",@_)))[0];
+ my($path) = shift;
+
+ _strip_trailing_sep($path);
+ my($basename, $dirname) = fileparse( $path, map("\Q$_\E",@_) );
+ $basename = $dirname unless length $basename;
+
+ return $basename;
}
--- lib/File/Basename.t 2005/07/07 20:55:38 1.1
+++ lib/File/Basename.t 2005/07/07 21:14:20
@@ -5,7 +5,7 @@
@INC = '../lib';
}
-use Test::More tests => 57;
+use Test::More tests => 60;
BEGIN { use_ok 'File::Basename' }
@@ -26,7 +26,6 @@
is(basename('/arma/virumque.cano'), 'virumque.cano');
is(dirname ('/arma/virumque.cano'), '/arma');
is(dirname('arma/'), '.');
- is(dirname('/'), '/');
}
@@ -131,6 +130,18 @@
}
+### rt.cpan.org 36477
+{
+ fileparse_set_fstype('Unix');
+ is(dirname('/'), '/');
+ is(basename('/'), '/');
+
+ fileparse_set_fstype('DOS');
+ is(dirname('\\'), '\\');
+ is(basename('\\'), '\\');
+}
+
+
### Test tainting
{
# The empty tainted value, for tainting strings
@@ -150,6 +161,7 @@
1;
}
+ fileparse_set_fstype 'Unix';
ok tainted(dirname($TAINT.'/perl/lib//'));
ok all_tainted(fileparse($TAINT.'/dir/draft.book7','\.book\d+'));
}
|
From @steve-m-hayMichael G Schwern wrote:
Thanks - applied as change 25096. Radan Computational Ltd. The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email. |
From @steve-m-hayNow fixed in bleadperl as noted above. |
@steve-m-hay - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#36477 (status was 'resolved')
Searchable as RT36477$
The text was updated successfully, but these errors were encountered: