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 
there.

Still, I think the find manual should first use the triple -exec example as 
today,
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 
real-life
examples would need to perform other checks.

Have a nice day,
Berny

Reply via email to