BTS

Message1888

Author ft
Recipients maddi, mika
Date 2009-02-14.21:43:23
Content
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
History
Date User Action Args
2009-02-14 21:43:23ftsetrecipients: + mika
2009-02-14 21:43:23ftlinkissue431 messages
2009-02-14 21:43:23ftcreate