From owner-freebsd-questions@FreeBSD.ORG Tue May 20 00:57:18 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D47A1065670 for ; Tue, 20 May 2008 00:57:18 +0000 (UTC) (envelope-from fbsd06+WD=b45b2392@mlists.homeunix.com) Received: from turtle-out.mxes.net (turtle-out.mxes.net [216.86.168.191]) by mx1.freebsd.org (Postfix) with ESMTP id 4ADE28FC17 for ; Tue, 20 May 2008 00:57:18 +0000 (UTC) (envelope-from fbsd06+WD=b45b2392@mlists.homeunix.com) Received: from mxout-03.mxes.net (mxout-03.mxes.net [216.86.168.178]) by turtle-in.mxes.net (Postfix) with ESMTP id 9DA88163F77 for ; Mon, 19 May 2008 20:41:37 -0400 (EDT) Received: from gumby.homeunix.com. (unknown [87.81.140.128]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTP id 28B7423E3EF for ; Mon, 19 May 2008 20:41:35 -0400 (EDT) Date: Tue, 20 May 2008 01:41:33 +0100 From: RW To: freebsd-questions@freebsd.org Message-ID: <20080520014133.3447c282@gumby.homeunix.com.> In-Reply-To: <20080519094603.GC12033@osiris.chen.org.nz> References: <7d6fde3d0805190149y7a3bfa75j2ca6a67cef66e8f6@mail.gmail.com> <20080519094603.GC12033@osiris.chen.org.nz> X-Mailer: Claws Mail 3.4.0 (GTK+ 2.12.9; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: Now what would you expect this to print out? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 May 2008 00:57:18 -0000 On Mon, 19 May 2008 21:46:03 +1200 Jonathan Chen wrote: > On Mon, May 19, 2008 at 01:49:35AM -0700, Garrett Cooper wrote: > > Riddle for the day for folks that have source trees... what would > > you expect this to print out (ask yourself the question and then > > execute the command)? > > > > find /usr/src -name Makefile -or -name '*.mk' -print > > > > The expected output and what actual output differed in my mind, but > > maybe somebody else can "shed some light" on the logic behind what > > happened > > It's a problem that catches many young players with find(1). One has > to remember from reading the man-page that all directives have an > implicit AND operator on it; and that includes the "-print" directive. > So to get what you want, you have to introduce brackets: > > find /usr/src \( -name Makefile -or -name '*.mk' \) -print > Why does that make a difference, when print always evaluates to true? x AND true = x so (a OR b) AND true = a OR b a OR (b AND true) = a OR b