[Top][All Lists]

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

Re: [PATCH] find: doc: Fix -prune SCM example and really make it efficie

From: Bernhard Voelker
Subject: Re: [PATCH] find: doc: Fix -prune SCM example and really make it efficient
Date: Wed, 26 Oct 2022 15:20:09 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0

On 10/26/22 11:33, James Youngman wrote:
The style "test X -o Y" is obsolescent in POSIX (citation: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html>).

The POSIX standard recommends the use instead of test X || test Y.   Which is, 
in effect, what we are doing in the existing code.

Supposing efficiency is an overriding concern we could use something like this:

-exec sh -c 'test -d "$1"/.svn || test -d "$1"/.git || test -d "$1"/CVS' fnord 
{} \;

The fnord there of course is assigned to $0.  The above would need careful 
testing for space handling in particular.

Thanks for the reminder - I had forgotten about that.
Personally I never use `test X -o Y` ... because of the ambiguity mentioned 

Still, I think the find manual should first use the triple -exec example as 
and then mention that this special case can be tuned by using the above '-exec 
sh -c ...'.

I believe documenting both ways is good because the tests for certain child 
names is
just a special case which can be done by the test utility - while other 
examples would need to perform other checks.

Have a nice day,

reply via email to

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