Files
bash/bash-20060316/examples/functions/inpath
T
2011-12-07 09:05:27 -05:00

15 lines
186 B
Plaintext

inpath()
{
local PROG
path=$(echo $PATH | sed 's/^:/.:/
s/::/:.:/g
s/:$/:./
s/:/ /g')
for x in $path
do
[ -x $x/$1 ] && { PROG=$x/$1; break; }
done
[ -n "$PROG" ]
}