Subject: Re: bin/12536: find defaults to -printing -pruned off -or expressions
To: None <jhawk@mit.edu>
From: Chris G. Demetriou <cgd@sibyte.com>
List: netbsd-bugs
Date: 04/04/2001 09:57:44
jhawk@mit.edu (John Hawkinson) writes:
> 	When the find command has two operands of an -or operator,
> if no -print is specified, it defaults to applying -print to both operands,
> not merely to the second operand.

Yes.  I believe that that's because the POSIX.2 standard said that
without an operator that caused 'output' (however they put that, iirc
the standard ones being being: -print, -ls, -exec), the behaviour
should be:

	( expression ) -print


> This seems hokey. The Solaris find doesn't have this problem,
> but gnu find appears to.

As far as I remember, solaris 'find' has historically been broken
w.r.t. -print.  my recollection is that it effectively tacks on -print
to the end, rather than doing The Right Thing.

(I checked another SVR4-ish system, Irix, and its find seems to behave
like our find.)


It's not clear that this is actually anything other than a manual page
problem.

My recollection is that our '-print' behaviour is correct, but that's
fuzzy since it dates back to '93 or '94, and I've never owned a
POSIX.2 document, but instead would just borrow the one that Bostic
had in the the CSRG office at Berkeley...  It was a small manual with
small print.  8-) I've seen online drafts that agreed, as i recall,
though.

The manual page is clear in its behaviour, but it isn't obvious to a
newcomer where that behaviour is documented.  In particular, the
description of the behaviour is hidden under the -print primary:

     -print  This primary always evaluates to true.  It prints the pathname of
             the current file to standard output, followed by a newline char-
             acter.  If none of -exec, -ls, -ok, -print0, nor -printx is spec-
             ified, the given expression shall be effectively replaced by
             (given expression) -print.



cgd