Bug 41453 - find . -prune does not add implicit -print
find . -prune does not add implicit -print
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: findutils (Show other bugs)
7.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Aaron Brown
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-05-20 16:11 EDT by Per Mildner
Modified: 2007-04-18 12:33 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-12-06 19:05:56 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Per Mildner 2001-05-20 16:11:40 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)

Description of problem:
Earlier versions of find prints '.' when called as
'find . -prune'. This is consistent with the ocumentation.
find 4.1.6 (as shipped with RedHat 7.1) prints nothing in this case,
adding an explicit -print makes it print '.'.


How reproducible:
Always

Steps to Reproduce:
1.find . -prune
2.
3.
	

Actual Results:  no output

Expected Results:  should have printed '.'

Additional info:

Earlier versions of find prints '.' when called as
'find . -prune'. This is consistent with the ocumentation.
find 4.1.6 (as shipped with RedHat 7.1) prints nothing in this case,
adding an explicit -print makes it print '.'.

My guess as to why this happens is:
From ChangeLog:
2000-05-13  Kevin Dalley  <kevind@rahul.net>
...
	* find/parser.c (parse_prune): set side_effects to true, to
	prevent prune from being moved in opt_expr.

Which corresponds to the code:
parser.c:
static boolean
parse_prune (char **argv, int *arg_ptr)
{
  struct predicate *our_pred;

  our_pred = insert_primary (pred_prune);
  our_pred->need_stat = false;
  /* -prune has a side effect that it does not descend into
     the current directory. */
  our_pred->side_effects = true;
  return (true);
}

However, having side_effects is interpreted as 'producing output' in
find.c, thus preventing an implicit '-print' from being added:

  else if (!no_side_effects (predicates->pred_next)) <<< [PM] (probably) 
true for -prune in 4.1.6
    {
      /* One or more predicates that produce output were given;
	 remove the unneeded initial `('. */
      cur_pred = predicates;
      predicates = predicates->pred_next;
      free ((char *) cur_pred);
    }
  else <<< [PM] (probably) -prune got here in earlier releases
    {
      /* `( user-supplied-expression ) -print'. */
      parse_close (argv, &argc);
      parse_print (argv, &argc);
    }

This analysis is based only on a brief review of the source, I have
not tried to verify it by compiling/debugging/whatever.

This bug breaks the installation script for one of our software
packages (the workaround for us is to explicitly add -print)
Comment 1 Tim Waugh 2001-12-07 11:17:28 EST
This seems to be fixed in findutils-4.1.7-1.

Note You need to log in before you can comment on or make changes to this bug.