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 follow_fast => 1 loses dangling symlink #7241
Comments
From @mjdominusCreated by @mjdominus my $DIR = shift || "/tmp/T"; use File::Find; When the 'follow_fast' option is supplied, the 'find' function fails Perl Info
|
From @smpeters
The attached patches fix this problem. From my tests, the problem could --- /home/steve/perl-current/lib/File/Find.pm 2004-02-27 @@ -126,7 +126,8 @@ There is a variable C<$File::Find::fullname> which holds the absolute =back @@ -1101,7 +1102,21 @@ # ignore if invalid symlink if (-d _) { --- /home/steve/perl-current/lib/File/Find/t/find.t 2004-03-31 %Expect_File = (File::Spec->curdir => 1, Check( scalar(keys %Expect_File) == 0 ); + Check( $warn_msg =~ m|dangling_file_sl is a dangling symbolic @@ -750,10 +751,7 @@ @@ -814,13 +812,10 @@ } |
From @smpetersfind_t.patch--- /home/steve/perl-current/lib/File/Find/t/find.t 2004-03-31 02:47:28.000000000 -0600
+++ t/find.t 2004-11-11 20:08:26.000000000 -0600
@@ -661,6 +661,7 @@
use warnings;
%Expect_File = (File::Spec->curdir => 1,
+ file_path('dangling_file_sl') => 1,
file_path('fa_ord') => 1,
file_path('fsl') => 1,
file_path('fb_ord') => 1,
@@ -684,7 +685,7 @@
topdir('dangling_dir_sl'), topdir('fa') );
Check( scalar(keys %Expect_File) == 0 );
- Check( $warn_msg =~ m|dangling_dir_sl is a dangling symbolic link| );
+ Check( $warn_msg =~ m|dangling_file_sl is a dangling symbolic link| );
unlink file_path('fa', 'dangling_file_sl'),
file_path('dangling_dir_sl');
@@ -750,10 +751,7 @@
File::Find::finddepth( {wanted => \&wanted_File_Dir, follow => 1,
follow_skip => 1, no_chdir => 1},
topdir('fa') );
-
- Check( scalar(keys %Expect_File) == 1 );
- # Only the file and its symlink have value 2;<
- Check( (values %Expect_File)[0] == 2);
+ Check( scalar(keys %Expect_File) == 0 );
unlink file_path('fa', 'fa_ord_sl');
@@ -814,13 +812,10 @@
# If we encountered the symlink first, then the entries corresponding to
# the real name remain, if the real name first then the symlink
my @names = sort keys %Expect_File;
- Check( @names == 2 );
- # In sorted order the directory name comes first
- Check ($names[1] =~ /^$names[0]/);
+ Check( @names == 1 );
# Normalise both to the original name
s/_sl// foreach @names;
- Check ($names[0] eq file_path_name('fa', 'faa'));
- Check ($names[1] eq file_path_name('fa', 'faa', 'faa_ord'));
+ Check ($names[0] eq file_path_name('fa', 'faa', 'faa_ord'));
unlink file_path('fa', 'faa_sl');
}
|
From @smpetersFile_Find_pm.patch--- /home/steve/perl-current/lib/File/Find.pm 2004-02-27 10:48:42.000000000 -0600
+++ ./lib/File/Find.pm 2004-11-11 20:00:42.000000000 -0600
@@ -3,7 +3,7 @@
use strict;
use warnings;
use warnings::register;
-our $VERSION = '1.07';
+our $VERSION = '1.08';
require Exporter;
require Cwd;
@@ -126,7 +126,8 @@
=item *
There is a variable C<$File::Find::fullname> which holds the absolute
-pathname of the file with all symbolic links resolved
+pathname of the file with all symbolic links resolved. If the link is
+a dangling symbolic link, then fullname will be set to C<undef>.
=back
@@ -1101,7 +1102,21 @@
$new_loc = Follow_SymLink($loc_pref.$FN);
# ignore if invalid symlink
- next unless defined $new_loc;
+ unless (defined $new_loc) {
+ if ($dangling_symlinks) {
+ if (ref $dangling_symlinks eq 'CODE') {
+ $dangling_symlinks->($FN, $dir_pref);
+ } else {
+ warnings::warnif "$dir_pref$FN is a dangling symbolic link\n";
+ }
+ }
+
+ $fullname = undef;
+ $name = $dir_pref . $FN;
+ $_ = ($no_chdir ? $name : $FN);
+ { $wanted_callback->() };
+ next;
+ }
if (-d _) {
push @Stack,[$new_loc,$updir_loc,$dir_name,$FN,1];
|
The RT System itself - Status changed from 'new' to 'open' |
From @rgsSteve Peters via RT wrote:
Thanks, applied as #23510. |
@rgs - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#28929 (status was 'resolved')
Searchable as RT28929$
The text was updated successfully, but these errors were encountered: