Closed p5pRT closed 20 years ago
find2perl doesn's call &wanted with correct arguments in some cases
Given the environment
mkdir /tmp/testfind2perl cd /tmp/testfind2perl
Please consider the following where find and find2perl agree: touch f ln -s f q find q -type l -print q # prints q
find2perl q -type l -print > qf perl qf ./q # prints ./q (but close enough for my purposed this time)
Now observe this case using symbolic links to directories mkdir d ln -s d qd find qd -type l -print qd # prints qd as desired
find2perl qd -type l -print > qdf perl qdf
prints nothing
I added the following line my the sub wanted in qdf print "\$dir=$dir\, \$name=$name\, \$_=$_\n";
so now wanted looks like: sub wanted { my ($dev\,$ino\,$mode\,$nlink\,$uid\,$gid); print "\$dir=$dir\, \$name=$name\, \$_=$_\n";
(($dev\,$ino\,$mode\,$nlink\,$uid\,$gid) = lstat($_)) && -l _ && print("$name\n"); }
This seems to show that wanted is not called with the correct arguments
$dir=qd\, $name=qd\, $_=.
At least the lstat of $_ doesn't stat the file "qd" that I desire that it should.
According to the documentation
The wanted() function does whatever verifications you want.
`$File::Find::dir' contains the current directory name\, and
`$_' the current filename within that directory.
`$File::Find::name' contains the complete pathname to the
file. You are chdir()'d to `$File::Find::dir' when the
function is called\, unless `no_chdir' was specified. When
\
and find2perl inserted the aliases into the script it generates *name = *File::Find::name; *dir = *File::Find::dir;
$dir=qd\, $name=qd\, $_=.
When $_ is "."\, the -l _ test fails\, even though the argument File::Find::find({wanted => \&wanted}\, 'qd'); explicitly list 'qd' as the file to be tested.
If I apply the following patch to File::Find\, so the non -follow path does an lstat instead of a stat\, then the symbolic link to directory finds and prints the desired information like find does.
Thanks\, applied.
Maybe add the test case to t/lib/filefind.t (only if symlinks are supported\, of course?)
Maybe add the test case to t/lib/filefind.t (only if symlinks are supported\, of course?)
This will pass when Change 10308 has been applied\, and it will fail appropriately when 10308 is not applied if symlinks are available:
Migrated from rt.perl.org#7056 (status was 'resolved')
Searchable as RT7056$