On Thu, Mar 26, 2015 at 1:48 AM, Dale R. Worley <wor...@alum.mit.edu> wrote: > Peng Yu <pengyu...@gmail.com> 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.
While I agree with you from a technical point of view, had find been implemented the other way (figuring out the absolute path to the utility on startup) I would not find this a convincing argument to change that hypothetical existing implementation :) > 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 >