I'd like to know if it's possible to write a POSIX compliant script that builds a find command from it'sits arguments.
The way to do it for Bash (and zsh) is explained in this other SE article but it's using facilities that are Bashbash (or zsh) specific.
The original question was to be able to build a find command like this:
find -iname '*foo*' -o -iname '*bar*' -o -iname '*blah*'
The answer is with the following Bash script code:
findany() {
local args=('-iname' "*$1*")
shift
while [ "$#" -gt 0 ]; do
args+=('-o' '-iname' "*$1*")
shift
done
find . "${args[@]}"
}
Is it possible to do something similar in a POSIX-compliant script?