bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #26281] find -depth sometimes visits nodes in the wrong order


From: James Youngman
Subject: [bug #26281] find -depth sometimes visits nodes in the wrong order
Date: Tue, 21 Apr 2009 22:41:46 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.7) Gecko/2009032813 Iceweasel/3.0.6 (Debian-3.0.6-1)

Follow-up Comment #1, bug #26281 (project findutils):

It appears that find is using gnulib's ftp() implementation in a way that
isn't guaranteed to order visits to files and subdirectories in any given
order.  FTS_D and FTS_DP can be used to consider subdirectores before parent
directories, but this does not guarantee anything about the relative ordering
of return of files in the parent directory, as compared to sudirectories in
that parent.   

Here is an illustration of a possible execution of 
"find dir -depth -name Makefile.am -print".  

The table has 3 columns.   The first is the value of fts_info when fts_read
returns.  The second is the filename (fts_info->fts_path).   The third is
PRINT if the -print succeeds there.

FTS_D     dir 
FTS_NSOK  dir/foo
FTS_NSOK  dir/Makefile.am  PRINT
FTS_D     dir/m4
FTS_NSOK  dir/m4/Makefile.am PRINT
FTS_DP    dir/m4
FTS_NSOK  dir/bar
FTS_DP    dir

So here, find will print ...
  dir/Makefile.am
  dir/m4/Makefile.am
... when clearly the user expected the opposite order.

The correct approach may well be simply to pass an appropriate comparison
function to fts_open, so that files are visited last in -depth traversals. 
>From my reading of the documentation FTS_NSOK is never returned for
directories, which would be a required property in order for this strategy to
work. 


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?26281>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]