#! /bin/sh

# A version of 'which' that doesn't rerun your .cshrc and trash PATH.

opath=$PATH
PATH=/bin:/usr/bin

case $# in
0)	echo 'Usage: witch command' 1>&2; exit 2
esac

for i in `echo $opath | sed 's/^:/.:/
			     s/::/:.:/g
			     s/:$/:./
			     s/:/ /g'`
do
	if test -f $i/$1
	then
		echo $i/$1
		exit 0
	fi
done
echo "No $1 in $opath" 1>&2
exit 1
