bug-findutils
[Top][All Lists]
Advanced

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

Re: -exec test (use which to only find test once)


From: Dale R. Worley
Subject: Re: -exec test (use which to only find test once)
Date: Wed, 25 Mar 2015 21:48:14 -0400

Peng Yu <address@hidden> writes:
> I find that "-exec test ..." can be slower than "-exec $(which test)
> ...". Is possible that `find` internally use "which", so that users
> don't need to explicitly call it?

It's possible, I suppose, but the semantics of -exec can be changed by
turning the program name into a specific path.  Consider

   find / -name rm -exec rm {} \;

As processing deletes files named 'rm', which program is executed by
"-exec rm" can change.

Also, there is no certainty that 'which' carries out exactly the same
search process as the kernel calls execlp()/execvp().

I can see that there are times when you'd want to do this, but it seems
to me that explicitly writing $(which prog) isn't difficult and makes
explicit how you're modifying the semantics of 'fimd'.

Dale



reply via email to

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