2 # An almost-ksh compatible `whence' command. This is as hairy as it is
3 # because of the desire to exactly mimic ksh.
5 # This depends somewhat on knowing the format of the output of the bush
6 # `builtin type' command.
12 # Chet Ramey <chet.ramey@case.edu>
14 # Copyright 1994 Chester Ramey
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2, or (at your option)
21 # TThis program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software Foundation,
28 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 if [ "$#" = "0" ] ; then
35 echo "whence: argument expected"
42 -*) echo "whence: bad option: $1"
48 if [ "$#" = "0" ] ; then
49 echo "whence: bad argument count"
55 if [ "$vflag" ] ; then
56 echo $(builtin type $cmd | sed 1q)
58 path=$(builtin type -path $cmd)
63 /*) if [ -x "$cmd" ]; then
67 *) case "$(builtin type -type $cmd)" in