I'm trying to use a bash function from find. I know that I need to export the function. When I do this from the command line it works. When I do it from within a bash script it doesn't. the code is listed below. if you execute it doesn't work. if you source it, then it does. What is interesting, is that once you source it, the script will then work because it's defined at the time of the script invocation.
#!/bin/bash
function doit {
echo args "<$@>"
}
doit a b c
export -f doit
find . -maxdepth 1 -exec sh -c 'doit "$@" ' {} \+
here's the error I see:
> ./x.sh
args <a b c>
.: doit: command not found