-
Notifications
You must be signed in to change notification settings - Fork 1
/
.ashtype
68 lines (67 loc) · 1.87 KB
/
.ashtype
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# .ashtype - This should be, but is not, a builtin in /bin/ash
#
# Copyright (c) Greg A. Woods 1996. All rights reserved.
#
# This software is not subject to any license of the American Telephone
# and Telegraph Company, the Regents of the University of California, or
# the Free Software Foundation.
#
# Permission is granted to anyone to use this software for any purpose on
# any computer system, and to alter it and redistribute it freely, subject
# to the following restrictions:
#
# 1. The authors are not responsible for the consequences of use of this
# software, no matter how awful, even if they arise from flaws in it.
#
# 2. The origin of this software must not be misrepresented, either by
# explicit claim or by omission. Since few users ever read sources,
# credits must appear in any relevant documentation.
#
# 3. Altered versions must be plainly marked as such, and must not be
# misrepresented as being the original software. Since few users
# ever read sources, credits must appear in any relevant documentation.
#
# 4. This notice may not be removed or altered.
#
#
#ident "@(#)HOME:.ashtype 37.1 21/03/23 11:43:05 (woods)"
type ()
{
if [ $# -ne 1 ] ; then
echo "Usage: type command" >&2
return 2
fi
functions=`hash | grep "function $1\$"`
if [ -n "$functions" ] ; then
echo "$functions" | sed 's/^\([^ ]*\) \(.*\)$/\2 is a \1/'
unset functions
return 0
fi
unset functions
rc=1
case "$1" in
.|alias|bg|command|echo|eval|exec|exit|export|fg|getopts|hash|jobid|jobs|pwd|read|readonly|return|set|setvar|shift|trap|umask|unset|wait)
typeout="$1 is a builtin"
rc=0
;;
*)
typeout="$1 not found"
oifs="$IFS"
IFS=":"
for pathseg in $PATH
do
if [ -x $pathseg/$1 ] ; then
typeout="$1 is $pathseg/$1"
rc=0
break
fi
done
IFS="$oifs"
unset oifs
;;
esac
echo $typeout
unset hashv pathseg typeout
return $rc
}