#! /bin
:
#ident "@(#)	Rory Hammond -PN1 - /usr/lbin/wh"
# 07-11-93   replaced C program with this shell
#
#	wh
#
#	Examine the path for a command & tell which dir has it. Stop with
#       the 1st dir that has it.
#
#

if [ $# -eq 0 ]
then
	echo "usage:\t$0 prognam ...." >&2
	exit 1
fi

dirs=`echo $PATH |
       sed -e 's/^:/.:/' -e 's/:$/:./' -e 's/::/:.:/' -e 's/:/ /g'`

notfound=

for ffile in $*
do
	found=0

	for dir in $dirs
	do 
		if [ -x ${dir}/${ffile} -a ! -d "${dir}/$1" ]
		then
			echo ${dir}/${ffile}
			found=1
			break
		fi
	done

	if [ ${found} -eq 0 ]
	then
		notfound="${notfound} $1"
	fi

	shift
done

#report the not found

for arg in $notfound
do
	echo "${arg} not found"
done

exit 0
