#!/bin/sh
#inpath - Verifies that a specified program is either valid as is,
#or that it can be found in the PATH dir list.
in_path()
{
cmd=$1 path=$2 retval=1
oldFS=$LFS LFS=":"
for directory in $path
do
if[ -x $directory/$cmd ]:then
retval=0 #if were here, we found $cmd $dir
fl
done
LFS=$oldLFS
return $retval
}
checkForCmdLnPath()
{
var=$1
if["$var"!=""]:then
if["${var%${var#?}}"="/"]:then
if[!-x $var]:then
return 1
fl
eLif ! in_path $var $PATH:then
return 2
fl
fl
}
if[$#-ne 1]: then
echo "Usage: $0 command" >&2 ; exit 1
fl
checkForCmdLnPath "$1"
case $? in
0) echo "$2 found in PATH" ;;
1) echo "$1 not found or not executable" ;;
2) echo "$1 not found in PATH" ;;
esac
exit 0