Skip Menu |

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

Report information
The Basics
Id: 64775
Status: resolved
Priority: 0/
Queue: File-Util

People
Owner: Nobody in particular
Requestors: artg [...] cs.nyu.edu
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 3.27
Fixed in: (no value)



Subject: --pattern doesn't work with --recurse in list_dir
--pattern doesn't filter files found in recursion Perhaps the bug's in the recursive part of list_dir, which doesn't pass --pattern my(@lsts) = $this->list_dir ( $dirs[$i], '--with-paths', '--dirs-as-ref', '--files-as-ref', '--recursing', '--no-fsdots', '--max-dives=' . $maxd ); perl -v This is perl, v5.8.9 built for darwin-2level uname -a Darwin LSKI1167.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386
From: kes-kes [...] yandex.ru
The bug is next: 1. Directory is checked by pattern 2. If match - files in directory is listed 3. If not match - files in directory is not listed --- Util.pm.orig 2012-08-13 19:16:01.000000000 +0300 +++ Util.pm 2012-08-13 19:28:48.000000000 +0300 @@ -205,9 +205,14 @@ # platforms I've run code on, but just in case...) rewinddir(DIR); You can apply this patch: /usr/local/lib/perl5/site_perl/5.16.0/File --- Util.pm.orig 2012-08-13 19:16:01.000000000 +0300 +++ Util.pm 2012-08-13 19:28:48.000000000 +0300 - @files = exists($opts->{'--pattern'}) - ? grep(/$opts->{'--pattern'}/, readdir(DIR)) - : readdir(DIR); + if( exists($opts->{'--file-pattern'}) ) { + @files = grep( -d $_ || -f $_ && /$opts->{'--file-pattern'}/, readdir(DIR) ); + } + else { + @files = exists($opts->{'--pattern'}) + ? grep(/$opts->{'--pattern'}/, readdir(DIR)) + : readdir(DIR); + } and use --file-pattern instead of --pattern
From: kes-kes [...] yandex.ru
yes, you are right, bug is there
RT-Send-CC: kes-kes [...] yandex.ru
I'm evaluating your patch Eugen. I am going to take action to correct the bug as originally reported, but I am concerned with creating ambiguity/confusion by adding support for "--file-pattern" in addition to the already existing "--pattern" flag. If we do this, should we consider the following: 1. We add "--file-pattern" and enforce it on files 2. We add "--dir-pattern" and enforce it on directories 3. We enforce "--pattern" on _all_ file system object types. My only worry with the ideas above lies with #3 because if I start enforcing the existing flag on all file system object types, this might break code that uses File::Util and depends on/expects the old behavior. What are your thoughts? I'm also going to ask for the opinions of the Perl monks. -- Tommy Butler
From: kes-kes [...] yandex.ru
Show quoted text
> What are your thoughts? I'm also going to ask for the opinions of the > Perl monks.
I think you can add warn about that that option is depricated. Also test code accurate, becase of current realization is buggy. Also you can change version of module and notify about options incompotibility
On Sun Sep 30 02:50:50 2012, kes-kes@yandex.ru wrote: Show quoted text
> I think you can add warn about that that option is depricated. Also
test Show quoted text
> code accurate, becase of current realization is buggy. > > Also you can change version of module and notify about options > incompotibility
I just uploaded version 3.31 to CPAN. It should appear soon. In the new version I added a new option "--rpattern" which is applied recursively. This preserves the behavior for "--pattern" so that existing applications don't break. For now, please consider this resolved. I'm considering adding "--fpattern" to apply only to files, "--dpattern" to apply only to directories, "--rfpattern" to apply recursively only to files, and "--rdpattern" to apply recursively only to directories. I'll ask perlmonks for feedback on this idea.