Frank Terbeck <ft@bewatermyfriend.org>:
> is_installed() {
> prog="$1"
>
> ret=1
> oifs="$IFS"
> IFS=:
> for dir in $PATH; do
> [ -x "${dir:-.}/$1" ] && ret=0
Thinking more about it, this is probably better done like this:
[ -x "${dir:-/bin}/$1" ] && ret=0
Why? Well, /bin is probably in everybody's $PATH and using '.' would
sneak . into $PATH (well, not really but for the test if $PATH is
something like PATH=/bin:/sbin::/usr/bin) which is something *nobody*
wants.
> done
>
> IFS="$oifs"
> return "$ret"
> }
Regards, Frank |