Well, let me make a fresh start... :-)
I think this will make a final usable version.
[snip]
is_installed() {
prog="$1"
[ -z "$prog" ] && return 1
ret=1
oifs="$IFS"
IFS=:
for dir in $PATH; do
[ -z "$dir" ] && continue
[ -x "$dir/$prog" ] && ret=0
done
IFS="$oifs"
unset oifs
return "$ret"
}
[snap]
Works in posh, dash, bash ksh93 and mksh and in zsh's sh mode(at
least, I did test those). Cannot work in zsh mode, because $PATH
won't split without sh_word_split set.
Then again, in zsh mode, this would be done a *lot* differently.
So, I'm happy with this now.
Sometimes, sleep really helps. :)
Regards, Frank |