On Tue, Sep 14, 2010 at 02:48:01PM +0100, Jason McIntyre wrote:
> On Tue, Sep 14, 2010 at 01:42:17PM +0200, Joachim Schipper wrote:
> > On Mon, Sep 13, 2010 at 08:01:28PM +0100, Jason McIntyre wrote:
> > > On Mon, Sep 13, 2010 at 02:49:58PM +0200, Joachim Schipper wrote:
> > > > The first diff changes the last example in find(1). This diff:
> > > > (...)
> > > > - adds handling of *.gif files to illustrate ordering;
> > > 
> > > but we already have an example that does this:
> > > 
> > >   Print out a list of all the files which are not both newer than
> > >   ``ttt'' and owned by ``wnj'':
> > > 
> > >           $ find / \! \( -newer ttt -user wnj \)
> > > 
> > > i think that covers it well enough.
> > 
> > In the message to bugs@ that started this thread, djm@ got the ordering
> > of -o, specifically, wrong. I agree that the order of "and" is obvious,
> > but reasonable people can clearly believe that
> > 
> >     $ find . -name \*.jpg -o -name \*.gif -print0
> > 
> > will print both *.jpg and *.gif files.
> 
> the poster closed that bug report with the words (from memory) "i should
> have rtfm".

I don't disagree with you that this is already in the man page; but this
change will prevent people from making the same mistake (i.e. has an
upside) and doesn't appear to have any significant downsides (unlike the
second diff, the first adds very little text to the page.)

You seem a reasonable enough fellow, and I see you've worked on find.1
in the past. I don't see why you're so adamantly opposed. Care to
enlighten me?

> > There is merit in being concise, but:
> > - this should be under CAVEATS, no matter where else it appears (i.e. if
> >   you want to prevent duplication, remove it elsewhere);
> 
> where you put this information is a matter of taste. there is nothing,
> nothing, which says it must go in CAVEATS. it might turn out that that
> is the best place for it, but in that case the diff should subtract the
> information already contained.

I think this is something that people using find should be warned about,
hence CAVEATS. Putting it only in the discussion of -X, as in the
previous version, means it doesn't reach people who don't read the
entire page.

> > - getting this wrong is a somewhat serious security problem, and tons of
> >   people get it wrong. Repeating it doesn't hurt.
> 
> right. so please add this information five times, so that for sure
> people will read it.

Would you be happier with a version with less repetition? The following
diff is like the one I sent out earlier, but
- shorten the reference from "-X" to "-print0"
- removes the warning from the description of -print (people using
  "-print" instead of letting find(1) add it by default will probably
  look at CAVEATS too);

With the attached diff, the man page refers to this issue in "-X" and
"-print0" and CAVEATS; would you like to see it removed from one of
these places?

                Joachim

Index: find.1
===================================================================
RCS file: /cvs/src/usr.bin/find/find.1,v
retrieving revision 1.78
diff -u -p -r1.78 find.1
--- find.1      15 Jul 2010 20:51:38 -0000      1.78
+++ find.1      14 Sep 2010 14:49:42 -0000
@@ -126,13 +126,9 @@ quotes, backslash
 space, tab, and newline
 .Pq Sq \en
 characters.
-Alternatively, the
+Consider using
 .Fl print0
-primary may be used in conjunction with the
-.Fl 0
-option to
-.Xr xargs 1 ,
-allowing all file names to be processed safely.
+instead.
 .It Fl x
 Prevents
 .Nm
@@ -386,7 +382,10 @@ character.
 .It Ic -print0
 This primary always evaluates to true.
 It prints the pathname of the current file to standard output, followed
-by a null character.
+by a null character, suitable for use with the
+.Fl 0
+option to
+.Xr xargs 1 .
 .It Ic -prune
 This primary always evaluates to true.
 It causes
@@ -525,11 +524,13 @@ ending in a dot and single digit, but sk
 .Pp
 .Dl "$ find /usr/src -path /usr/src/gnu -prune -or -name \e*.[0-9]"
 .Pp
-Find and remove all *.jpg files in the current working directory:
+Find and remove all *.jpg and *.gif files under the current working
+directory
+.Pq see also Sx CAVEATS :
 .Pp
-.Dl "$ find . -name \e*.jpg -exec rm {} \e;"
+.Dl "$ find . \e( -name \e*.jpg -o -name \e*.gif \e) -exec rm {} \e;
 or
-.Dl "$ find . -name \e*.jpg | xargs rm"
+.Dl "$ find . \e( -name \e*.jpg -o -name \e*.gif \e) -print0 | xargs -0r rm"
 .Sh SEE ALSO
 .Xr chflags 1 ,
 .Xr chmod 1 ,
@@ -637,6 +638,25 @@ In particular, the characters
 and
 .Ql \&;
 may have to be escaped from the shell.
+.Pp
+Using
+.Nm
+in combination with
+other programs requires some care:
+.Pp
+.Dl "$ find . -name \e*.jpg | xargs rm"
+or
+.Dl "$ rm `find . -name \e*.jpg`"
+.Pp
+would, given a file named
+.Pa "important .jpg"
+(with a space character in the middle), remove
+.Pa important .
+Use the
+.Ic -print0
+or
+.Ic -exec
+primaries instead.
 .Pp
 As there is no delimiter separating options and file names or file
 names and the

Reply via email to