[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: -exec test (use which to only find test once)
From: |
James Youngman |
Subject: |
Re: -exec test (use which to only find test once) |
Date: |
Sat, 28 Mar 2015 22:34:15 +0000 |
On Thu, Mar 26, 2015 at 1:48 AM, Dale R. Worley <address@hidden> wrote:
> 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.
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
>