All pastes #39530 Raw Edit

Something

public text v1 · immutable
#39530 ·published 2006-02-01 21:40 UTC
rendered paste body
twb@rocinante[~]$ PATH='/bin:/usr/bin:/usr/local/bin'
twb@rocinante[~]$ _twb_which () {
>     # succeed iff "$1" is in $PATH
>     if test 1 -eq $#
>     then
>         echo "$PATH" | sed -e 's/:/\n/g' | while read p
>         do
>             if test -x "$p/$1"
>             then return 0
>             fi
>         done
>     else
>         echo 'Wrong number of arguments.' 2>&1
>     fi
>     return 1
> }
twb@rocinante[~]$ set -x
twb@rocinante[~]$ _twb_which mg
+ _twb_which mg
+ test 1 -eq 1
+ sed -e 's/:/\n/g'
+ read p
+ echo /bin:/usr/bin:/usr/local/bin
+ test -x /bin/mg
+ read p
+ test -x /usr/bin/mg
+ return 0
+ return 1
twb@rocinante[~]$