I'm writing a shell script to run on a docker image based on Alpine. It's shell is /bin/sh
.
What I'm trying to do is execute a function for the results of a find
command. The following works in my local bash
and sh
shells.
myscript.sh:
#!/bin/sh
function get_tags {
# do stuff
}
export -f get_tags
# get all YAML files in ./assets/config that have 'FIND' somewhere in the filename
# pass each to the get_tags function
find ./assets/config -type f \( -iname "Find*.yaml" -or -iname "Find*.yml" \) -exec sh -c 'get_tags "$0"' {} \;
When I run it on the alpine image, however, I get the following error:
./myscript.sh: export: line 31: illegal option -f
Is there another way I can do this?
My question is NOT "what is the difference between sh
and bash
". My question is: how do I accomplish the task of running a function on the output of the find
command.