#!/bin/sh # which --- show first instance of program in path # Author: Noah Friedman # Created: 1991-07-17 # Last modified: 1994-03-09 # Public domain. if test $# = 0; then echo "Usage: which {prog}" 1>&2 exit 1 fi case $1 in /* ) if test -f "$1"; then echo "$1" exit 0; fi ;; esac path=`echo $PATH | sed -e 's/^:/.:/;s/::/:.:/g;s/:$/:./;s/:/ /g'` for p in $path ; do if test -f "$p/$1" ; then echo "$p/$1" exit 0 fi done exit 1 # which ends here