1 ## oils_failures_allowed: 0
2 ## compare_shells: bash zsh mksh dash ash
3
4 #### type -> keyword builtin
5
6 type while cd
7
8 ## STDOUT:
9 while is a shell keyword
10 cd is a shell builtin
11 ## END
12 ## OK zsh/mksh STDOUT:
13 while is a reserved word
14 cd is a shell builtin
15 ## END
16
17 #### type -> alias external
18
19 shopt -s expand_aliases || true # bash
20
21 alias ll='ls -l'
22
23 touch _tmp/date
24 chmod +x _tmp/date
25 PATH=_tmp:/bin
26
27 normalize() {
28 # ignore quotes and backticks
29 # bash prints a left backtick
30 quotes='"`'\'
31 sed \
32 -e "s/[$quotes]//g" \
33 -e 's/shell function/function/' \
34 -e 's/is aliased to/is an alias for/'
35 }
36
37 type ll date | normalize
38
39 # Note: both procs and funcs go in var namespace? So they don't respond to
40 # 'type'?
41
42 ## STDOUT:
43 ll is an alias for ls -l
44 date is _tmp/date
45 ## END
46 ## BUG mksh STDOUT:
47 ll is an alias for ls -l
48 date is a tracked alias for _tmp/date
49 ## END
50
51 #### type of relative path
52
53 touch _tmp/file _tmp/ex
54 chmod +x _tmp/ex
55
56 type _tmp/file _tmp/ex
57
58 # dash and ash don't care if it's executable
59 # mksh
60
61 ## status: 1
62 ## STDOUT:
63 _tmp/ex is _tmp/ex
64 ## END
65
66 ## OK mksh/zsh STDOUT:
67 _tmp/file not found
68 _tmp/ex is _tmp/ex
69 ## END
70
71 ## BUG dash/ash status: 0
72 ## BUG dash/ash STDOUT:
73 _tmp/file is _tmp/file
74 _tmp/ex is _tmp/ex
75 ## END
76
77 #### type -> not found
78
79 type zz 2>err.txt
80 echo status=$?
81
82 # for bash and OSH: print to stderr
83 fgrep -o 'zz: not found' err.txt || true
84
85 # zsh and mksh behave the same - status 1
86 # dash and ash behave the same - status 127
87
88 ## STDOUT:
89 status=1
90 zz: not found
91 ## END
92
93 ## OK mksh/zsh STDOUT:
94 zz not found
95 status=1
96 ## END
97 ## STDERR:
98 ## END
99
100 ## BUG dash/ash STDOUT:
101 zz: not found
102 status=127
103 ## END
104 ## BUG dash/ash STDERR:
105 ## END
106
107 #### special builtins are called out
108 type cd
109 type eval
110 type :
111 type true
112
113 echo
114 type export
115
116 ## STDOUT:
117 cd is a shell builtin
118 eval is a special shell builtin
119 : is a special shell builtin
120 true is a shell builtin
121
122 export is a special shell builtin
123 ## END
124
125 ## N-I bash STDOUT:
126 cd is a shell builtin
127 eval is a shell builtin
128 : is a shell builtin
129 true is a shell builtin
130
131 export is a shell builtin
132 ## END
133
134 ## N-I zsh STDOUT:
135 cd is a shell builtin
136 eval is a shell builtin
137 : is a shell builtin
138 true is a shell builtin
139
140 export is a reserved word
141 ## END
142
143 #### more special builtins
144 case $SH in bash|zsh|dash) exit ;; esac
145
146 type .
147 type source
148
149 # no agreement here!
150 # type local
151 # type typeset
152
153 ## STDOUT:
154 . is a special shell builtin
155 source is a shell builtin
156 ## END
157
158 ## BUG ash STDOUT:
159 . is a special shell builtin
160 source is a special shell builtin
161 ## END
162
163 ## N-I bash/zsh/dash STDOUT:
164 ## END