-
-
Notifications
You must be signed in to change notification settings - Fork 150
/
builtin-type.test.sh
117 lines (91 loc) · 1.75 KB
/
builtin-type.test.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
## oils_failures_allowed: 0
## compare_shells: bash zsh mksh dash ash
#### type -> keyword builtin
type while cd
## STDOUT:
while is a shell keyword
cd is a shell builtin
## END
## OK zsh/mksh STDOUT:
while is a reserved word
cd is a shell builtin
## END
#### type -> alias function external
shopt -s expand_aliases || true # bash
alias ll='ls -l'
f() { echo hi; }
touch _tmp/date
chmod +x _tmp/date
PATH=_tmp:/bin
# ignore quotes and backticks
# bash prints a left backtick
quotes='"`'\'
type ll f date | sed "s/[$quotes]//g"
# Note: both procs and funcs go in var namespace? So they don't respond to
# 'type'?
## STDOUT:
ll is an alias for ls -l
f is a shell function
date is _tmp/date
## END
## OK ash STDOUT:
ll is an alias for ls -l
f is a function
date is _tmp/date
## END
## OK mksh STDOUT:
ll is an alias for ls -l
f is a function
date is a tracked alias for _tmp/date
## END
## OK bash STDOUT:
ll is aliased to ls -l
f is a function
f ()
{
echo hi
}
date is _tmp/date
## END
#### type of relative path
touch _tmp/file _tmp/ex
chmod +x _tmp/ex
type _tmp/file _tmp/ex
# dash and ash don't care if it's executable
# mksh
## status: 1
## STDOUT:
_tmp/ex is _tmp/ex
## END
## OK mksh/zsh STDOUT:
_tmp/file not found
_tmp/ex is _tmp/ex
## END
## BUG dash/ash status: 0
## BUG dash/ash STDOUT:
_tmp/file is _tmp/file
_tmp/ex is _tmp/ex
## END
#### type -> not found
type zz 2>err.txt
echo status=$?
# for bash and OSH: print to stderr
fgrep -o 'zz: not found' err.txt || true
# zsh and mksh behave the same - status 1
# dash and ash behave the same - status 127
## STDOUT:
status=1
zz: not found
## END
## OK mksh/zsh STDOUT:
zz not found
status=1
## END
## STDERR:
## END
## BUG dash/ash STDOUT:
zz: not found
status=127
## END
## BUG dash/ash STDERR:
## END