Subject: | problem with trailing slashes and './' |
Hi,
the in() method in File::Find::Rule functions wrong when
$File::Find::name is the current directory with several trailing
slashes. Examples are './/' and './//'. The former doesn't match
anything at all, while the latter converts to (wrong) absolute paths.
A sample program follows:
use File::Find::Rule;
$rule=File::Find::Rule->new->start($ARGV[0]);
while ($f = $rule->match ) {
print "$f\n";
}
When run with args './', './/' and './//', it gives different results. I
have verified this on Debian GNU/Linux (i386), Perl 5.8.8 and
File::Find::Rule 0.28 and 0.29.
I'm attaching a patch that seems to fix this. Please consider including it.
For reference, this bug was originally reported as Debian bug #329377,
http://bugs.debian.org/329377 , by Gabor Kiss.
Cheers,
--
Niko Tyni (on behalf of the Debian Perl Group)
ntyni@iki.fi
Subject: | rule.patch |
--- File-Find-Rule-0.29/lib/File/Find/Rule.pm 2006-05-16 17:27:00.000000000 +0300
+++ File-Find-Rule-0.29-fixed/lib/File/Find/Rule.pm 2006-05-27 20:19:55.220933683 +0300
@@ -540,7 +540,7 @@
my $topdir;
my $code = 'sub {
- (my $path = $File::Find::name) =~ s#^\./##;
+ (my $path = $File::Find::name) =~ s#^\./+([^/]+)#$1#;
my @args = ($_, $File::Find::dir, $path);
my $maxdepth = $self->{maxdepth};
my $mindepth = $self->{mindepth};