From 39829cd7cc5f0c88a0946cc65e25566c15a18d8e Mon Sep 17 00:00:00 2001 From: jay Date: Tue, 27 Nov 2007 20:50:18 +0000 Subject: [PATCH] Savannah bug #20803: -prune should always return true --- ChangeLog | 8 ++++++++ NEWS | 7 +++++++ doc/find.texi | 2 +- find/find.1 | 8 +++----- find/pred.c | 8 ++++++-- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 674246d..53c3659 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-11-27 James Youngman + + * 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. + 2007-11-26 James Youngman Fix Savannah bug #20970, handling of trailing slashes with -name. 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 -perm +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 +bugfix). + + ** 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 interp http://www.opengroup.org/austin/interps/uploads/40/14959/AI-186.txt +#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. .RE .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. -Because -\-delete implies \-depth, you cannot usefully use \-prune and \-delete -together. +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 && S_ISDIR(stat_buf->st_mode)) 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; } boolean -- 2.11.4.GIT