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::Find has issues with symlinks #8620
Comments
From ammon@rhythm.comCreated by ammon@rhythm.comThere are several issues with File::Find, and how it deals with * It reports non-existing files, when using follow or follow_fast. lid3213:> perl -MFile::Find=find -e'find({wanted => sub { print "$_\n" } }, "/nosuchfile")' As you can see above, this behaviour is only exhibited when following * $File::Find::fullname does not have '..' reduced correctly when #!/usr/local/bin/perl5 use warnings; use File::Find; my $root = "/tmp/perlbug1"; symlink "..", "$root/dir/link_to_parent" or die $!; File::Find::find({ wanted => sub { print "$File::Find::fullname\n"}, lid3213:> perl bug.pl Since the directory path is correctly reduced for other cases of * $File::Find::fullname is undef in some cases, particularly with (This doesn't exist in version 1.07, due to a bug which prevents #!/usr/local/bin/perl5 use warnings; use File::Find; my $root = "/tmp/perlbug2; symlink "dangling", "$root/dangler" or die $!; File::Find::find( __END__ lid3213:> perl bug.pl * Doubled directory separators ("//") are not properly reduced. #!/usr/local/bin/perl5 use warnings; use File::Find; my $root = "/tmp/perlbug3"; -d "$root/dir" or mkdir "$root/dir" or die $!; File::Find::find( __END__ lid3213:> perl bug.pl Looking at the code, this appears not to be a problem for the MacOS. * Using the 'follow' option only reports the first link, or file #!/usr/local/bin/perl5 use warnings; use File::Find; my $root = "/tmp/perlbug4"; -d "$root/dir" or mkdir "$root/dir" or die $!; open F, ">$root/a" and close F or die $!; symlink "$root/a", "$root/link_to_a" or die $!; my $pat = " %-30s => %-30s\n"; print "Found:\n"; File::Find::find({ print "Expected:\n"; File::Find::find({ __END__ lid3213:> perl bug.pl There are a couple reasons why this is a problem. First, if the Second, using 'follow' or 'follow_fast' is the only way to a) ensure According to the documentation, when using 'follow', File::Find builds There is only one way to achieve the expected output: my %seenFiles = (); return if $seenFiles{$dev, $inode}++; printf $pat, $_, $File::Find::fullname; File::Find::find({ The problem with this solution is two-fold. First, you have to duplicate Obtaining the observed behaviour from a File::Find module that works in Although the following patch changes File::Find to exhibit the expected Inline Patch
Perl Info
|
From @rgsammon@rhythm.com (via RT) wrote:
Thanks for your insighful treatment of the problem, and your patch. |
The RT System itself - Status changed from 'new' to 'open' |
From david.pitt@nab.com.auOn Wed Oct 04 01:15:40 2006, rgarciasuarez@mandriva.com wrote:
It's a shame ammon didn't come up with patches for the test cases, but /tmp> ls -lR testdir testdir/d: |
From @tonycozOn Tue Sep 26 20:38:36 2006, ammon@rhythm.com wrote:
If you (or anyone else) could supply an update to this patch that Thanks, |
Migrated from rt.perl.org#40417 (status was 'open')
Searchable as RT40417$
The text was updated successfully, but these errors were encountered: