CARVIEW |
Select Language
HTTP/2 200
cache-control: max-age=43200
server: Combust/Plack (Perl)
vary: Accept-Encoding
content-encoding: gzip
content-length: 1922
content-type: text/html; charset=utf-8
last-modified: Sun, 12 Oct 2025 20:50:44 GMT
traceparent: 03a0ed76b39acd8749ce5c2a9e2fb0a1
strict-transport-security: max-age=15768000
[perl #123672] File::Find return symlink to follow_skip==2 - nntp.perl.org
Front page | perl.perl5.porters |
Postings from January 2015
nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About

[perl #123672] File::Find return symlink to follow_skip==2
From:
John DoeDate:
January 25, 2015 19:28Subject:
[perl #123672] File::Find return symlink to follow_skip==2Message ID:
rt-4.0.18-9293-1422187023-616.123672-75-0@perl.org# New Ticket Created by John Doe # Please include the string: [perl #123672] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=123672 > # perldoc File::Find > > "follow" > Causes symbolic links to be followed. > ... > There is a variable $File::Find::fullname which holds the > absolute pathname of the file with all symbolic links resolved. > ... > "follow_skip==2" causes File::Find to ignore any duplicate files and > directories but to proceed normally otherwise. I got next result: # create files $ mkdir -p a/b b; touch a/b/X; ln -s ../a/b/X b/ # test.pl use File::Find; find( { wanted => sub{ /X$/o && print $File::Find::fullname,"\n"}, follow => 1, follow_skip => 2 }, '.'); # result: $ perl test.pl /tmp/test_box2/a/b/X /tmp/test_box2/b/X # <-- got symlink in result Is that wrong behavior for follow => 1 and follow_skip => 2 options ? What's going on? sub Follow_SymLink($) { .. while (-l _) { # <-- 1. true ... $NewName= PathCombine($AbsName, readlink($AbsName)); # <-- 2. $NewName keep true filename ... if ($full_check && defined $DEV && $SLnkSeen{$DEV, $INO}++) { # 3. <-- [!] TRUE for $SLnkSeen{$DEV, $INO} if ( ($follow_skip < 1) || ((-d _) && ($follow_skip < 2)) ) { die "$AbsName encountered a second time"; } else { return undef; # <-- 4. our exit point } } ... } sub _find_dir_symlnk($$$) { ... # follow symbolic links / do an lstat $new_loc = Follow_SymLink($loc_pref.$FN); # <-- 1. we got undef for symlink # ignore if invalid symlink unless (defined $new_loc) { if (!defined -l _ && $dangling_symlinks) { # <-- 2. false ... } else { $fullname = $loc_pref . $FN; # <-- 3. so, full filename point to symlink, not content } $name = $dir_pref . $FN; $_ = ($no_chdir ? $name : $FN); { $wanted_callback->() }; # <-- 4. callback got symlink in result next; } ... }
- [perl #123672] File::Find return symlink to follow_skip==2 by John Doe
nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About