foo() { bar --baz "$@"; frob --baz "$@"; }; find . -exec foo {} +
find . -exec sh -c 'bar --baz "$@"; frob --baz "$@";' -- {} +
Shell functions are only known to the shell. External commands like find, xargs, su and sudo do not recognize shell functions.
find
xargs
su
sudo
Instead, the function contents can be executed in a shell, either through sh -c or by creating a separate shell script as an executable file.
sh -c
If you're intentionally passing a word that happens to have the same name as a declared function, you can quote it to make shellcheck ignore it, e.g.
nobody() { sudo -u "nobody" "$@" }
There was an error while loading. Please reload this page.