Bug 41453 - find . -prune does not add implicit -print
Summary: find . -prune does not add implicit -print
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: findutils
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Aaron Brown
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-05-20 20:11 UTC by Per Mildner
Modified: 2007-04-18 16:33 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-12-07 00:05:56 UTC
Embargoed:


Attachments (Terms of Use)

Description Per Mildner 2001-05-20 20:11:40 UTC
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>
...
	* 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 16:17:28 UTC
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.