[Top][All Lists]

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

[Findutils-patches] [PATCH] Fix bug #20803, -prune should always return

From: James Youngman
Subject: [Findutils-patches] [PATCH] Fix bug #20803, -prune should always return true
Date: Sun, 25 Nov 2007 12:36:09 +0000

2007-11-25  James Youngman  <address@hidden>

        * find/pred.c (pred_prune): Always return true.  This fixes
        Savannah bug #20803.
        * doc/find.texi (Directories): Document the change to -prune.
        * find/find.1: Document the change.
        * NEWS: Mention the fix.
 NEWS          |    7 +++++++
 doc/find.texi |    2 +-
 find/find.1   |    8 +++-----
 find/pred.c   |    8 ++++++--
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index b88c754..12f2478 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,10 @@ When the POSIXLY_CORRECT environment variable is set, "find 
 +a+w" is rejected as invalid.  Some other similar mode strings
 starting with '+' which are not valid in POSIX are also rejected.
+The -prune action now always evaluates as true (this is also a
 ** Bug Fixes
 #21039: Setting the POSIXLY_CORRECT environment variable now turns off
 warnings by default, because POSIX requires that only diagnostic
@@ -17,6 +21,9 @@ messages must also result in a nonzero exit status.
 foo/ -name foo" now correctly matches foo and printf foo/.  See POSIX
+#20803: POSIX requires that -prune always returns true.  Previously it
+returned false when -depth was in effect and true otherwise.
 ** Documentation Fixes
 #21270: Formatting fixes to the xargs.1 manual page, including making
diff --git a/doc/find.texi b/doc/find.texi
index 9302015..0eca9a5 100644
--- a/doc/find.texi
+++ b/doc/find.texi
@@ -1334,7 +1334,7 @@ find . -wholename './src/emacs' -prune , -print
 If the @samp{-depth} option is in effect, the subdirectories will have
 already been visited in any case.  Hence @samp{-prune} has no effect
-and returns false.   
+in this case.   
 Because @samp{-delete} implies @samp{-depth}, using @samp{-prune} in
 combination with @samp{-delete} may well result in the deletion of
diff --git a/find/find.1 b/find/find.1
index de3dda5..1f3a49e 100644
--- a/find/find.1
+++ b/find/find.1
@@ -1115,11 +1115,9 @@ section for information about how unusual characters in 
filenames are handled.
 .IP \-prune
-If \-depth is not given, true; if the file is a directory, do not descend
-into it. If \-depth is given, false; no effect.
-\-delete implies \-depth, you cannot usefully use \-prune and \-delete
+True; if the file is a directory, do not descend into it. If \-depth
+is given, false; no effect.  Because \-delete implies \-depth, you
+cannot usefully use \-prune and \-delete together. 
 .IP "\-quit"
 Exit immediately.  No child processes will be left running, but no more
diff --git a/find/pred.c b/find/pred.c
index 2eb0f32..7fe81e9 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -1581,12 +1581,16 @@ pred_prune (const char *pathname, struct stat 
*stat_buf, struct predicate *pred_
   (void) pathname;
   (void) pred_ptr;
-  if (options.do_dir_first == true &&
+  if (options.do_dir_first == true && /* no effect with -depth */
       stat_buf != NULL &&
     state.stop_at_current_level = true;
-  return (options.do_dir_first); /* This is what SunOS find seems to do. */
+  /* findutils used to return options.do_dir_first here, so that -prune
+   * returns true only if -depth is not in effect.   But POSIX requires 
+   * that -prune always evaluate as true.
+   */
+  return true;

reply via email to

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