On Thu, Nov 13, 2008 at 09:50:17AM +0100, Christian Kellermann wrote:
> * Trent W. Buck <[EMAIL PROTECTED]> [081113 08:19]:
> > Yay, consensus. Would you please amend and re-send your patch to use
> > {} \; (instead of xargs)?
>
> I think we have a misunderstanding here.
>
> The original line in GNUmakefile reads:
> find src \( -name \*.o -o -name \*.hi \) -exec rm -rf {} + ;
Not quite, there is no semicolon there at all.
find DIRECTORY ... PREDICATE ... -exec rm -f {} +
On compliant systems, this turns into
rm -f foo bar baz quux quuux # ...
rm -f quuuuuuuuuuuuux
i.e. it calls "rm -f" as few times as possible. Rather like xargs,
only you don't have to worry about record separators, because there is
no stream involved.
> which causes OpenBSD to fail:
> find: -exec: no terminating ";"
> gmake: *** [clean] Error 1
Clearly OpenBSD does not understand "-exec rm -f {} +", so it is
assuming we are using "-exec rm -f {} \;" -- which calls rm -f once
per file.
> A solution that works on OpenBSD would be:
> find src \( -name \*.o -o -name \*.hi \) -exec rm -rf {} + \;
Sorry, that's wrong. It would translate into
rm -f foo +
rm -f bar +
rm -f baz +
# ...
That is, it is the one-call-per-match style, but ALSO passing a
literal "+" argument to rm -f. Fortunately rm -f won't do anything
with it because we have no file called "+", but it is wrong
nonetheless.
> But this causes MacOS X to fail:
> find src \( -name \*.o -o -name \*.hi \) -exec rm -f {} + \;
> find: ;: unknown option
> make: *** [clean] Error 1
Because OS X *does* (presumably) support the newer variadic style
(-exec {} +), it gets that far and then tries sees the literal
semicolon argument where it expects a PREDICATE operator like -name or -o.
> Hence this dance. The issue is not the '+' part (this was my mistake)
> but the ";". Now as I am not a shell wizard, there may be a much
> easier solution to this.
The solution is either to use xargs (yuk) or to accept that we will be
calling rm -f once per match, and use the older non-variadic style:
find src \( -name \*.o -o -name \*.hi \) -exec rm -f {} \;
I nearly did this in the original patch, but I was hoping that by now
everybody used systems that met the current POSIX standard (at least
in this respect).
In this particular case, it doesn't matter much that we're calling rm
once per match, because there are only some tens of matches.
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users