1 | ## oils_failures_allowed: 0
|
2 | ## compare_shells: dash bash mksh zsh ash
|
3 |
|
4 | #### builtin declare a=(x y) is allowed
|
5 | case $SH in dash|zsh|mksh|ash) exit ;; esac
|
6 |
|
7 | $SH -c 'declare a=(x y); declare -p a'
|
8 | if test $? -ne 0; then
|
9 | echo 'fail'
|
10 | fi
|
11 |
|
12 | $SH -c 'builtin declare a=(x y); declare -p a'
|
13 | if test $? -ne 0; then
|
14 | echo 'fail'
|
15 | fi
|
16 |
|
17 | $SH -c 'builtin declare -a a=(x y); declare -p a'
|
18 | if test $? -ne 0; then
|
19 | echo 'fail'
|
20 | fi
|
21 |
|
22 | ## BUG bash STDOUT:
|
23 | declare -a a=([0]="x" [1]="y")
|
24 | fail
|
25 | fail
|
26 | ## END
|
27 |
|
28 | ## STDOUT:
|
29 | declare -a a=(x y)
|
30 | declare -a a=(x y)
|
31 | declare -a a=(x y)
|
32 | ## END
|
33 |
|
34 | ## N-I dash/zsh/mksh/ash STDOUT:
|
35 | ## END
|
36 |
|
37 |
|
38 | #### command export,readonly
|
39 | case $SH in zsh) exit ;; esac
|
40 |
|
41 | # dash doesn't have declare typeset
|
42 |
|
43 | command export c=export
|
44 | echo c=$c
|
45 |
|
46 | command readonly c=readonly
|
47 | echo c=$c
|
48 |
|
49 | echo --
|
50 |
|
51 | command command export cc=export
|
52 | echo cc=$cc
|
53 |
|
54 | command command readonly cc=readonly
|
55 | echo cc=$cc
|
56 |
|
57 | ## STDOUT:
|
58 | c=export
|
59 | c=readonly
|
60 | --
|
61 | cc=export
|
62 | cc=readonly
|
63 | ## END
|
64 | ## N-I zsh STDOUT:
|
65 | ## END
|
66 |
|
67 | #### command local
|
68 |
|
69 | f() {
|
70 | command local s=local
|
71 | echo s=$s
|
72 | }
|
73 |
|
74 | f
|
75 |
|
76 | ## STDOUT:
|
77 | s=local
|
78 | ## END
|
79 |
|
80 | ## BUG dash/ash STDOUT:
|
81 | s=
|
82 | ## END
|
83 |
|
84 | ## N-I mksh/zsh STDOUT:
|
85 | s=
|
86 | ## END
|
87 |
|
88 | #### export, builtin export
|
89 |
|
90 | x='a b'
|
91 |
|
92 | export y=$x
|
93 | echo $y
|
94 |
|
95 | builtin export z=$x
|
96 | echo $z
|
97 |
|
98 | ## STDOUT:
|
99 | a b
|
100 | a b
|
101 | ## END
|
102 |
|
103 | ## BUG bash/mksh STDOUT:
|
104 | a b
|
105 | a
|
106 | ## END
|
107 |
|
108 | ## N-I dash STDOUT:
|
109 | a
|
110 |
|
111 | ## END
|
112 |
|
113 | ## N-I ash STDOUT:
|
114 | a b
|
115 |
|
116 | ## END
|
117 |
|
118 | #### \builtin declare - ble.sh relies on it
|
119 | case $SH in dash|mksh|ash) exit ;; esac
|
120 |
|
121 | x='a b'
|
122 |
|
123 | builtin declare c=$x
|
124 | echo $c
|
125 |
|
126 | \builtin declare d=$x
|
127 | echo $d
|
128 |
|
129 | 'builtin' declare e=$x
|
130 | echo $e
|
131 |
|
132 | b=builtin
|
133 | $b declare f=$x
|
134 | echo $f
|
135 |
|
136 | b=b
|
137 | ${b}uiltin declare g=$x
|
138 | echo $g
|
139 |
|
140 | ## STDOUT:
|
141 | a b
|
142 | a b
|
143 | a b
|
144 | a b
|
145 | a b
|
146 | ## END
|
147 |
|
148 | ## BUG bash STDOUT:
|
149 | a
|
150 | a
|
151 | a
|
152 | a
|
153 | a
|
154 | ## END
|
155 |
|
156 | ## N-I dash/ash/mksh STDOUT:
|
157 | ## END
|
158 |
|
159 | #### \command readonly - similar issue
|
160 | case $SH in zsh) exit ;; esac
|
161 |
|
162 | # \command readonly is equivalent to \builtin declare
|
163 | # except dash implements it
|
164 |
|
165 | x='a b'
|
166 |
|
167 | readonly b=$x
|
168 | echo $b
|
169 |
|
170 | command readonly c=$x
|
171 | echo $c
|
172 |
|
173 | \command readonly d=$x
|
174 | echo $d
|
175 |
|
176 | 'command' readonly e=$x
|
177 | echo $e
|
178 |
|
179 | # The issue here is that we have a heuristic in EvalWordSequence2:
|
180 | # fs len(part_vals) == 1
|
181 |
|
182 | ## STDOUT:
|
183 | a b
|
184 | a b
|
185 | a b
|
186 | a b
|
187 | ## END
|
188 |
|
189 | ## BUG bash STDOUT:
|
190 | a b
|
191 | a
|
192 | a
|
193 | a
|
194 | ## END
|
195 |
|
196 | # note: later versions of dash are fixed
|
197 | ## BUG dash STDOUT:
|
198 | a
|
199 | a
|
200 | a
|
201 | a
|
202 | ## END
|
203 |
|
204 | ## N-I zsh STDOUT:
|
205 | ## END
|
206 |
|
207 | #### Dynamic $c readonly - bash and dash change behavior, mksh bug
|
208 | case $SH in zsh) exit ;; esac
|
209 |
|
210 | x='a b'
|
211 |
|
212 | z=command
|
213 | $z readonly c=$x
|
214 | echo $c
|
215 |
|
216 | z=c
|
217 | ${z}ommand readonly d=$x
|
218 | echo $d
|
219 |
|
220 | ## STDOUT:
|
221 | a b
|
222 | a b
|
223 | ## END
|
224 |
|
225 | ## BUG bash/dash STDOUT:
|
226 | a
|
227 | a
|
228 | ## END
|
229 |
|
230 | ## BUG mksh status: 2
|
231 | ## BUG mksh STDOUT:
|
232 | a
|
233 | ## END
|
234 |
|
235 | ## N-I zsh STDOUT:
|
236 | ## END
|
237 |
|
238 |
|
239 | #### static builtin command ASSIGN, command builtin ASSIGN
|
240 | case $SH in dash|ash|zsh) exit ;; esac
|
241 |
|
242 | # dash doesn't have declare typeset
|
243 |
|
244 | builtin command export bc=export
|
245 | echo bc=$bc
|
246 |
|
247 | builtin command readonly bc=readonly
|
248 | echo bc=$bc
|
249 |
|
250 | echo --
|
251 |
|
252 | command builtin export cb=export
|
253 | echo cb=$cb
|
254 |
|
255 | command builtin readonly cb=readonly
|
256 | echo cb=$cb
|
257 |
|
258 | ## STDOUT:
|
259 | bc=export
|
260 | bc=readonly
|
261 | --
|
262 | cb=export
|
263 | cb=readonly
|
264 | ## END
|
265 | ## N-I dash/ash/zsh STDOUT:
|
266 | ## END
|
267 |
|
268 | #### dynamic builtin command ASSIGN, command builtin ASSIGN
|
269 | case $SH in dash|ash|zsh) exit ;; esac
|
270 |
|
271 | b=builtin
|
272 | c=command
|
273 | e=export
|
274 | r=readonly
|
275 |
|
276 | $b $c export bc=export
|
277 | echo bc=$bc
|
278 |
|
279 | $b $c readonly bc=readonly
|
280 | echo bc=$bc
|
281 |
|
282 | echo --
|
283 |
|
284 | $c $b export cb=export
|
285 | echo cb=$cb
|
286 |
|
287 | $c $b readonly cb=readonly
|
288 | echo cb=$cb
|
289 |
|
290 | echo --
|
291 |
|
292 | $b $c $e bce=export
|
293 | echo bce=$bce
|
294 |
|
295 | $b $c $r bcr=readonly
|
296 | echo bcr=$bcr
|
297 |
|
298 | echo --
|
299 |
|
300 | $c $b $e cbe=export
|
301 | echo cbe=$cbe
|
302 |
|
303 | $c $b $r cbr=readonly
|
304 | echo cbr=$cbr
|
305 |
|
306 | ## STDOUT:
|
307 | bc=export
|
308 | bc=readonly
|
309 | --
|
310 | cb=export
|
311 | cb=readonly
|
312 | --
|
313 | bce=export
|
314 | bcr=readonly
|
315 | --
|
316 | cbe=export
|
317 | cbr=readonly
|
318 | ## END
|
319 | ## N-I dash/ash/zsh STDOUT:
|
320 | ## END
|
321 |
|
322 | #### builtin typeset, export,readonly
|
323 | case $SH in dash|ash) exit ;; esac
|
324 |
|
325 | builtin typeset s=typeset
|
326 | echo s=$s
|
327 |
|
328 | builtin export s=export
|
329 | echo s=$s
|
330 |
|
331 | builtin readonly s=readonly
|
332 | echo s=$s
|
333 |
|
334 | echo --
|
335 |
|
336 | builtin builtin typeset s2=typeset
|
337 | echo s2=$s2
|
338 |
|
339 | builtin builtin export s2=export
|
340 | echo s2=$s2
|
341 |
|
342 | builtin builtin readonly s2=readonly
|
343 | echo s2=$s2
|
344 |
|
345 | ## STDOUT:
|
346 | s=typeset
|
347 | s=export
|
348 | s=readonly
|
349 | --
|
350 | s2=typeset
|
351 | s2=export
|
352 | s2=readonly
|
353 | ## END
|
354 | ## N-I dash/ash STDOUT:
|
355 | ## END
|
356 |
|
357 | #### builtin declare,local
|
358 | case $SH in dash|ash|mksh) exit ;; esac
|
359 |
|
360 | builtin declare s=declare
|
361 | echo s=$s
|
362 |
|
363 | f() {
|
364 | builtin local s=local
|
365 | echo s=$s
|
366 | }
|
367 |
|
368 | f
|
369 |
|
370 | ## STDOUT:
|
371 | s=declare
|
372 | s=local
|
373 | ## END
|
374 | ## N-I dash/ash/mksh STDOUT:
|
375 | ## END
|
376 |
|