2 # whatis -- and implementation of the 10th Edition Unix sh builtin `whatis'
5 # usage: whatis arg [...]
7 # For each argument, whatis prints the associated value as a parameter,
8 # builtin, function, alias, or executable file as appropriate. In each
9 # case, the value is printed in a form which would yield the same value
10 # if typed as input to the shell itself.
13 # Chet Ramey <chet.ramey@case.edu>
15 # Copyright 1994 Chester Ramey
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2, or (at your option)
22 # TThis program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write to the Free Software Foundation,
29 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 local wusage='usage: whatis arg [arg...]'
37 if [ $# -eq 0 ] ; then
44 case $(builtin type -type $arg 2>/dev/null) in
49 builtin type "$arg" | sed 1d
55 builtin type -path "$arg"
58 # OK, we could have a variable, or we could have nada
59 if [ "$(eval echo \${$arg+set})" = "set" ] ; then
60 # It is a variable, and it is set
62 eval echo '\"'\$$arg'\"'
64 echo whatis: $arg: not found