develooper Front page | perl.perl5.porters | Postings from March 2019

[perl #133931] File::Find find() with "follow" option fails toinvoke "preprocess"

From:
Tony Cook via RT
Date:
March 19, 2019 00:23
Subject:
[perl #133931] File::Find find() with "follow" option fails toinvoke "preprocess"
Message ID:
rt-4.0.24-28869-1552955006-381.133931-15-0@perl.org
On Wed, 13 Mar 2019 15:21:38 -0700, mark.maimone@jpl.nasa.gov wrote:
> I noticed a disconnect between Find::File documentation and
> implementation.  It claims that "follow" and "preprocess" options can
> be used independently, but if I invoke Find::Find's "find()" using
> options that include "follow"ing symlinks, it never invokes the
> corresponding "preprocess" coderef option.  Looking at the Find.pm
> source, it's clear that only _find_dir() ever invokes "preprocess"
> (via local $pre_process); _find_dir_symlink() (which is called instead
> of _find_dir() when "follow" is set) never invokes it at all.

The documentation for File::Find states:

  =item C<preprocess>
  
  ...  When
  I<follow> or I<follow_fast> are in effect, C<preprocess> is a no-op.

This text was added in perl-5.6.0-4056-g7e47e6ffb6 (in 2001)

Could you please quote the text that indicates they are independent?

> 
> I was able to make things work (obeying "preprocess" hooks
> regardless of whether "follow" is also set) by duplicating the
> _find_dir() code in _find_dir_symlink(), adding the third line here:
> 
> @filenames = readdir DIR;
> closedir(DIR);
> @filenames = $pre_process->(@filenames) if $pre_process;
> 
> I would like to suggest including this or a similar change in
> new releases of File::Find.pm

That said, we could possibly allow preprocess to work with follow, but it's an enhancement, not a bug fix.

Tony


---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=133931



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About