[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Portability of find(1)

From: Paul Eggert
Subject: Re: Portability of find(1)
Date: Tue, 18 Sep 2001 09:47:47 -0700 (PDT)

> From: Sascha Schumann <address@hidden>
> Date: Tue, 18 Sep 2001 16:00:11 +0200 (CEST)
>     '{}' can only be used portably, if it is a separate argument.

It's worse than that.  Not only must '{}' be separate and not part of
any other argument, it must not be followed by another argument '+'.
If you write

       find . -exec chmod u+w {} +

then System V 'find' will execute a single 'chmod u+w' command,
passing it all the file name arguments, rather than one chmod command
for each file name found.  (If there are too many arguments for the
operating system, it will break it up into a few chmod commands.)

This is a nice feature, but the behavior is incompatible with
POSIX.2-1992.  For example, POSIX.2-1992 requires that:

  find / -type f -exec echo {} - ';' -o -exec echo {} + ';'

must print all files with a '-' after their name if they are regular
files and a '+' otherwise, but System V find reports an error for this

A few months ago I complained about this System V incompatibility with
POSIX -- and the response was to change POSIX to require the System V
behavior!  The behavior required by the next POSIX standard will not
be quite compatible with that of System V find, but it's close.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]