2 # which - emulation of `which' as it appears in FreeBSD
4 # usage: which [-as] command [command...]
9 local aflag sflag ES a opt
12 while builtin getopts as opt ; do
16 ?) echo "which: usage: which [-as] command [command ...]" >&2
21 (( $OPTIND > 1 )) && shift $(( $OPTIND - 1 ))
23 # without command arguments, exit with status 1
26 # exit status is 0 if all commands are found, 1 if any are not found
28 # if $command is a function, make sure we add -a so type
29 # will look in $PATH after finding the function
31 case "$(builtin type -t $command)" in
35 if [ -n "$sflag" ]; then
36 builtin type -p $a $command >/dev/null 2>&1
38 builtin type -p $a $command