bug-findutils
[Top][All Lists]
Advanced

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

Re: Allow `find` to use exported function for -exec*?


From: Dale R. Worley
Subject: Re: Allow `find` to use exported function for -exec*?
Date: Thu, 16 Apr 2015 23:20:06 -0400

Eric Blake <address@hidden> writes:
> On 04/15/2015 08:50 PM, Peng Yu wrote:
>> Hi, It seems that it might be convenient to allow `find` to use
>> exported functions from shell for -exec*? Can this feature be added in
>> the future?
>
> If your shell supports function exports, then the feature already
> exists.  Merely export the function before invoking find, and make sure
> that the -exec action of find invokes the same shell that knows how to
> use those exported functions in the environment.  And be careful of the
> bash shellshock bug.
>
> But there's nothing that can be added directly to find to change the
> situation.  Function exports is a property of the shell, not of find.

This depends subtly on how -exec is implemented.  If it's implemented
with one of the exec*() library functions (which I expect, given that
there's no warning about shell metacharacters in the find manual page),
the shell isn't invoked (assuming the program is directly executable and
not a script).

If you want to execute a shell exported function, you'd have to make
sure your shell interprets the program name.  For bash (and most
shells), the construction would be

    find ... -exec bash [function] [arg] [arg] ... \; ...

find invokes bash, and bash interprets "function" relative to exported
functions.

Dale



reply via email to

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