1 |
|
2 |
#### [bash_unset] local-unset / dynamic-unset for localvar |
3 |
unlocal() { unset -v "$1"; } |
4 |
|
5 |
f1() { |
6 |
local v=local |
7 |
unset v |
8 |
echo "[$1,local,(unset)] v: ${v-(unset)}" |
9 |
} |
10 |
v=global |
11 |
f1 global |
12 |
|
13 |
f1() { |
14 |
local v=local |
15 |
unlocal v |
16 |
echo "[$1,local,(unlocal)] v: ${v-(unset)}" |
17 |
} |
18 |
v=global |
19 |
f1 'global' |
20 |
|
21 |
## STDOUT: |
22 |
# bash-unset |
23 |
# local-unset = value-unset |
24 |
# dynamic-unset = cell-unset |
25 |
[global,local,(unset)] v: (unset) |
26 |
[global,local,(unlocal)] v: global |
27 |
## END |
28 |
|
29 |
## OK osh/mksh/yash STDOUT: |
30 |
# always-cell-unset |
31 |
# local-unset = cell-unset |
32 |
# dynamic-unset = cell-unset |
33 |
[global,local,(unset)] v: global |
34 |
[global,local,(unlocal)] v: global |
35 |
## END |
36 |
|
37 |
## OK zsh/ash/dash STDOUT: |
38 |
# always-value-unset |
39 |
# local-unset = value-unset |
40 |
# dynamic-unset = value-unset |
41 |
[global,local,(unset)] v: (unset) |
42 |
[global,local,(unlocal)] v: (unset) |
43 |
## END |
44 |
|
45 |
|
46 |
#### [bash_unset] local-unset / dynamic-unset for localvar (mutated from tempenv) |
47 |
unlocal() { unset -v "$1"; } |
48 |
|
49 |
f1() { |
50 |
local v=local |
51 |
unset v |
52 |
echo "[$1,local,(unset)] v: ${v-(unset)}" |
53 |
} |
54 |
v=global |
55 |
v=tempenv f1 'global,tempenv' |
56 |
|
57 |
f1() { |
58 |
local v=local |
59 |
unlocal v |
60 |
echo "[$1,local,(unlocal)] v: ${v-(unset)}" |
61 |
} |
62 |
v=global |
63 |
v=tempenv f1 'global,tempenv' |
64 |
|
65 |
## STDOUT: |
66 |
# bash-unset (bash-5.1) |
67 |
# local-unset = local-unset |
68 |
# dynamic-unset = cell-unset |
69 |
[global,tempenv,local,(unset)] v: (unset) |
70 |
[global,tempenv,local,(unlocal)] v: global |
71 |
## END |
72 |
|
73 |
## BUG bash STDOUT: |
74 |
# bash-unset (bash-4.3..5.0 bug) |
75 |
[global,tempenv,local,(unset)] v: global |
76 |
[global,tempenv,local,(unlocal)] v: global |
77 |
## END |
78 |
|
79 |
## OK osh/mksh/yash STDOUT: |
80 |
# always-cell-unset |
81 |
# local-unset = cell-unset |
82 |
# dynamic-unset = cell-unset |
83 |
[global,tempenv,local,(unset)] v: tempenv |
84 |
[global,tempenv,local,(unlocal)] v: tempenv |
85 |
## END |
86 |
|
87 |
## OK zsh/ash/dash STDOUT: |
88 |
# always-value-unset |
89 |
# local-unset = value-unset |
90 |
# dynamic-unset = value-unset |
91 |
[global,tempenv,local,(unset)] v: (unset) |
92 |
[global,tempenv,local,(unlocal)] v: (unset) |
93 |
## END |
94 |
|
95 |
|
96 |
#### [bash_unset] local-unset / dynamic-unset for tempenv |
97 |
unlocal() { unset -v "$1"; } |
98 |
|
99 |
f1() { |
100 |
unset v |
101 |
echo "[$1,(unset)] v: ${v-(unset)}" |
102 |
} |
103 |
v=global |
104 |
v=tempenv f1 'global,tempenv' |
105 |
|
106 |
f1() { |
107 |
unlocal v |
108 |
echo "[$1,(unlocal)] v: ${v-(unset)}" |
109 |
} |
110 |
v=global |
111 |
v=tempenv f1 'global,tempenv' |
112 |
|
113 |
## STDOUT: |
114 |
# always-cell-unset, bash-unset |
115 |
# local-unset = cell-unset |
116 |
# dynamic-unset = cell-unset |
117 |
[global,tempenv,(unset)] v: global |
118 |
[global,tempenv,(unlocal)] v: global |
119 |
## END |
120 |
|
121 |
## OK zsh/ash/dash/mksh STDOUT: |
122 |
# always-value-unset, mksh-unset |
123 |
# local-unset = value-unset |
124 |
# dynamic-unset = value-unset |
125 |
[global,tempenv,(unset)] v: (unset) |
126 |
[global,tempenv,(unlocal)] v: (unset) |
127 |
## END |
128 |
|
129 |
#### [bash_unset] function call with tempenv vs tempenv-eval |
130 |
unlocal() { unset -v "$1"; } |
131 |
|
132 |
f5() { |
133 |
echo "[$1] v: ${v-(unset)}" |
134 |
local v |
135 |
echo "[$1,local] v: ${v-(unset)}" |
136 |
( unset v |
137 |
echo "[$1,local+unset] v: ${v-(unset)}" ) |
138 |
( unlocal v |
139 |
echo "[$1,local+unlocal] v: ${v-(unset)}" ) |
140 |
} |
141 |
v=global |
142 |
f5 'global' |
143 |
v=tempenv f5 'global,tempenv' |
144 |
v=tempenv eval 'f5 "global,tempenv,(eval)"' |
145 |
|
146 |
## STDOUT: |
147 |
# bash-unset (bash-5.1) |
148 |
[global] v: global |
149 |
[global,local] v: (unset) |
150 |
[global,local+unset] v: (unset) |
151 |
[global,local+unlocal] v: global |
152 |
[global,tempenv] v: tempenv |
153 |
[global,tempenv,local] v: tempenv |
154 |
[global,tempenv,local+unset] v: (unset) |
155 |
[global,tempenv,local+unlocal] v: global |
156 |
[global,tempenv,(eval)] v: tempenv |
157 |
[global,tempenv,(eval),local] v: tempenv |
158 |
[global,tempenv,(eval),local+unset] v: (unset) |
159 |
[global,tempenv,(eval),local+unlocal] v: tempenv |
160 |
## END |
161 |
|
162 |
## BUG bash STDOUT: |
163 |
# bash-unset (bash-4.3..5.0 bug) |
164 |
[global] v: global |
165 |
[global,local] v: (unset) |
166 |
[global,local+unset] v: (unset) |
167 |
[global,local+unlocal] v: global |
168 |
[global,tempenv] v: tempenv |
169 |
[global,tempenv,local] v: tempenv |
170 |
[global,tempenv,local+unset] v: global |
171 |
[global,tempenv,local+unlocal] v: global |
172 |
[global,tempenv,(eval)] v: tempenv |
173 |
[global,tempenv,(eval),local] v: tempenv |
174 |
[global,tempenv,(eval),local+unset] v: (unset) |
175 |
[global,tempenv,(eval),local+unlocal] v: tempenv |
176 |
## END |
177 |
|
178 |
## OK ash STDOUT: |
179 |
# always-value-unset x init.unset |
180 |
[global] v: global |
181 |
[global,local] v: (unset) |
182 |
[global,local+unset] v: (unset) |
183 |
[global,local+unlocal] v: (unset) |
184 |
[global,tempenv] v: tempenv |
185 |
[global,tempenv,local] v: tempenv |
186 |
[global,tempenv,local+unset] v: (unset) |
187 |
[global,tempenv,local+unlocal] v: (unset) |
188 |
[global,tempenv,(eval)] v: tempenv |
189 |
[global,tempenv,(eval),local] v: (unset) |
190 |
[global,tempenv,(eval),local+unset] v: (unset) |
191 |
[global,tempenv,(eval),local+unlocal] v: (unset) |
192 |
## END |
193 |
|
194 |
## OK zsh STDOUT: |
195 |
# always-value-unset x init.empty |
196 |
[global] v: global |
197 |
[global,local] v: |
198 |
[global,local+unset] v: (unset) |
199 |
[global,local+unlocal] v: (unset) |
200 |
[global,tempenv] v: tempenv |
201 |
[global,tempenv,local] v: |
202 |
[global,tempenv,local+unset] v: (unset) |
203 |
[global,tempenv,local+unlocal] v: (unset) |
204 |
[global,tempenv,(eval)] v: tempenv |
205 |
[global,tempenv,(eval),local] v: |
206 |
[global,tempenv,(eval),local+unset] v: (unset) |
207 |
[global,tempenv,(eval),local+unlocal] v: (unset) |
208 |
## END |
209 |
|
210 |
## OK dash STDOUT: |
211 |
# always-value-unset x init.inherit |
212 |
[global] v: global |
213 |
[global,local] v: global |
214 |
[global,local+unset] v: (unset) |
215 |
[global,local+unlocal] v: (unset) |
216 |
[global,tempenv] v: tempenv |
217 |
[global,tempenv,local] v: tempenv |
218 |
[global,tempenv,local+unset] v: (unset) |
219 |
[global,tempenv,local+unlocal] v: (unset) |
220 |
[global,tempenv,(eval)] v: tempenv |
221 |
[global,tempenv,(eval),local] v: tempenv |
222 |
[global,tempenv,(eval),local+unset] v: (unset) |
223 |
[global,tempenv,(eval),local+unlocal] v: (unset) |
224 |
## END |
225 |
|
226 |
## OK osh/yash/mksh STDOUT: |
227 |
# always-cell-unset x init.unset |
228 |
[global] v: global |
229 |
[global,local] v: (unset) |
230 |
[global,local+unset] v: global |
231 |
[global,local+unlocal] v: global |
232 |
[global,tempenv] v: tempenv |
233 |
[global,tempenv,local] v: (unset) |
234 |
[global,tempenv,local+unset] v: tempenv |
235 |
[global,tempenv,local+unlocal] v: tempenv |
236 |
[global,tempenv,(eval)] v: tempenv |
237 |
[global,tempenv,(eval),local] v: (unset) |
238 |
[global,tempenv,(eval),local+unset] v: tempenv |
239 |
[global,tempenv,(eval),local+unlocal] v: tempenv |
240 |
## END |
241 |
|
242 |
|
243 |
#### [bash_unset] localvar-inherit from tempenv |
244 |
f1() { |
245 |
local v |
246 |
echo "[$1,(local)] v: ${v-(unset)}" |
247 |
} |
248 |
f2() { |
249 |
f1 "$1,(func)" |
250 |
} |
251 |
f3() { |
252 |
local v=local |
253 |
f1 "$1,local,(func)" |
254 |
} |
255 |
v=global |
256 |
|
257 |
f1 'global' |
258 |
v=tempenv f1 'global,tempenv' |
259 |
(export v=global; f1 'xglobal') |
260 |
|
261 |
f2 'global' |
262 |
v=tempenv f2 'global,tempenv' |
263 |
(export v=global; f2 'xglobal') |
264 |
|
265 |
f3 'global' |
266 |
|
267 |
## STDOUT: |
268 |
# init.bash |
269 |
# init.unset for local |
270 |
# init.inherit for tempenv |
271 |
[global,(local)] v: (unset) |
272 |
[global,tempenv,(local)] v: tempenv |
273 |
[xglobal,(local)] v: (unset) |
274 |
[global,(func),(local)] v: (unset) |
275 |
[global,tempenv,(func),(local)] v: tempenv |
276 |
[xglobal,(func),(local)] v: (unset) |
277 |
[global,local,(func),(local)] v: (unset) |
278 |
## END |
279 |
|
280 |
## OK osh/mksh/yash STDOUT: |
281 |
# init.unset |
282 |
[global,(local)] v: (unset) |
283 |
[global,tempenv,(local)] v: (unset) |
284 |
[xglobal,(local)] v: (unset) |
285 |
[global,(func),(local)] v: (unset) |
286 |
[global,tempenv,(func),(local)] v: (unset) |
287 |
[xglobal,(func),(local)] v: (unset) |
288 |
[global,local,(func),(local)] v: (unset) |
289 |
## END |
290 |
|
291 |
## OK ash STDOUT: |
292 |
# init.unset x tempenv-in-localctx |
293 |
[global,(local)] v: (unset) |
294 |
[global,tempenv,(local)] v: tempenv |
295 |
[xglobal,(local)] v: (unset) |
296 |
[global,(func),(local)] v: (unset) |
297 |
[global,tempenv,(func),(local)] v: (unset) |
298 |
[xglobal,(func),(local)] v: (unset) |
299 |
[global,local,(func),(local)] v: (unset) |
300 |
## END |
301 |
|
302 |
## OK zsh STDOUT: |
303 |
# init.empty |
304 |
[global,(local)] v: |
305 |
[global,tempenv,(local)] v: |
306 |
[xglobal,(local)] v: |
307 |
[global,(func),(local)] v: |
308 |
[global,tempenv,(func),(local)] v: |
309 |
[xglobal,(func),(local)] v: |
310 |
[global,local,(func),(local)] v: |
311 |
## END |
312 |
|
313 |
## OK dash STDOUT: |
314 |
# init.inherit |
315 |
[global,(local)] v: global |
316 |
[global,tempenv,(local)] v: tempenv |
317 |
[xglobal,(local)] v: global |
318 |
[global,(func),(local)] v: global |
319 |
[global,tempenv,(func),(local)] v: tempenv |
320 |
[xglobal,(func),(local)] v: global |
321 |
[global,local,(func),(local)] v: local |
322 |
## END |
323 |
|
324 |
|
325 |
#### [bash_unset] nested context by tempenv-eval |
326 |
f1() { |
327 |
local v=local1 |
328 |
echo "[$1,local1] v: ${v-(unset)}" |
329 |
v=tempenv2 eval ' |
330 |
echo "[$1,local1,tempenv2,(eval)] v: ${v-(unset)}" |
331 |
local v=local2 |
332 |
echo "[$1,local1,tempenv2,(eval),local2] v: ${v-(unset)}" |
333 |
' |
334 |
echo "[$1,local1] v: ${v-(unset)} (after)" |
335 |
} |
336 |
v=global |
337 |
v=tempenv1 f1 global,tempenv1 |
338 |
|
339 |
## STDOUT: |
340 |
# localvar-nest yes |
341 |
[global,tempenv1,local1] v: local1 |
342 |
[global,tempenv1,local1,tempenv2,(eval)] v: tempenv2 |
343 |
[global,tempenv1,local1,tempenv2,(eval),local2] v: local2 |
344 |
[global,tempenv1,local1] v: local1 (after) |
345 |
## END |
346 |
|
347 |
## OK mksh/ash/dash/yash STDOUT: |
348 |
# localvar-nest no |
349 |
[global,tempenv1,local1] v: local1 |
350 |
[global,tempenv1,local1,tempenv2,(eval)] v: tempenv2 |
351 |
[global,tempenv1,local1,tempenv2,(eval),local2] v: local2 |
352 |
[global,tempenv1,local1] v: local2 (after) |
353 |
## END |
354 |
|
355 |
#### [bash_unset] local-unset / dynamic-unset for localvar on nested-context |
356 |
unlocal() { unset -v "$1"; } |
357 |
|
358 |
f2() { |
359 |
local v=local1 |
360 |
v=tempenv2 eval ' |
361 |
local v=local2 |
362 |
(unset v ; echo "[$1,local1,tempenv2,(eval),local2,(unset)] v: ${v-(unset)}") |
363 |
(unlocal v; echo "[$1,local1,tempenv2,(eval),local2,(unlocal)] v: ${v-(unset)}") |
364 |
' |
365 |
} |
366 |
v=global |
367 |
v=tempenv1 f2 global,tempenv1 |
368 |
|
369 |
## STDOUT: |
370 |
# bash-unset (bash-5.1) |
371 |
[global,tempenv1,local1,tempenv2,(eval),local2,(unset)] v: (unset) |
372 |
[global,tempenv1,local1,tempenv2,(eval),local2,(unlocal)] v: local1 |
373 |
## END |
374 |
|
375 |
## BUG bash STDOUT: |
376 |
# bash-unset (bash-4.3..5.0 bug) |
377 |
[global,tempenv1,local1,tempenv2,(eval),local2,(unset)] v: local1 |
378 |
[global,tempenv1,local1,tempenv2,(eval),local2,(unlocal)] v: local1 |
379 |
## END |
380 |
|
381 |
## OK zsh/ash/dash STDOUT: |
382 |
# always-value-unset |
383 |
[global,tempenv1,local1,tempenv2,(eval),local2,(unset)] v: (unset) |
384 |
[global,tempenv1,local1,tempenv2,(eval),local2,(unlocal)] v: (unset) |
385 |
## END |
386 |
|
387 |
## OK osh STDOUT: |
388 |
# always-cell-unset x localvar-tempenv-share |
389 |
[global,tempenv1,local1,tempenv2,(eval),local2,(unset)] v: local1 |
390 |
[global,tempenv1,local1,tempenv2,(eval),local2,(unlocal)] v: local1 |
391 |
## END |
392 |
|
393 |
## OK mksh/yash STDOUT: |
394 |
# always-cell-unset (remove all localvar/tempenv) |
395 |
[global,tempenv1,local1,tempenv2,(eval),local2,(unset)] v: tempenv1 |
396 |
[global,tempenv1,local1,tempenv2,(eval),local2,(unlocal)] v: tempenv1 |
397 |
## END |
398 |
|
399 |
#### [bash_unset] dynamic-unset for nested localvars |
400 |
unlocal() { unset -v "$1"; } |
401 |
|
402 |
f3() { |
403 |
local v=local1 |
404 |
v=tempenv2 eval ' |
405 |
local v=local2 |
406 |
v=tempenv3 eval " |
407 |
local v=local3 |
408 |
echo \"[\$1/local1,tempenv2/local2,tempenv3/local3] v: \${v-(unset)}\" |
409 |
unlocal v |
410 |
echo \"[\$1/local1,tempenv2/local2,tempenv3/local3] v: \${v-(unset)} (unlocal 1)\" |
411 |
unlocal v |
412 |
echo \"[\$1/local1,tempenv2/local2,tempenv3/local3] v: \${v-(unset)} (unlocal 2)\" |
413 |
unlocal v |
414 |
echo \"[\$1/local1,tempenv2/local2,tempenv3/local3] v: \${v-(unset)} (unlocal 3)\" |
415 |
unlocal v |
416 |
echo \"[\$1/local1,tempenv2/local2,tempenv3/local3] v: \${v-(unset)} (unlocal 4)\" |
417 |
" |
418 |
' |
419 |
} |
420 |
v=global |
421 |
v=tempenv1 f3 global,tempenv1 |
422 |
|
423 |
## STDOUT: |
424 |
# cell-unset x localvar-tempenv-share x tempenv-in-localctx |
425 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: local3 |
426 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: local2 (unlocal 1) |
427 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: local1 (unlocal 2) |
428 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: global (unlocal 3) |
429 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: (unset) (unlocal 4) |
430 |
## END |
431 |
|
432 |
## OK zsh/ash/dash STDOUT: |
433 |
# value-unset |
434 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: local3 |
435 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: (unset) (unlocal 1) |
436 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: (unset) (unlocal 2) |
437 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: (unset) (unlocal 3) |
438 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: (unset) (unlocal 4) |
439 |
## END |
440 |
|
441 |
## OK osh STDOUT: |
442 |
# cell-unset x localvar-tempenv-share |
443 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: local3 |
444 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: local2 (unlocal 1) |
445 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: local1 (unlocal 2) |
446 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: tempenv1 (unlocal 3) |
447 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: global (unlocal 4) |
448 |
## END |
449 |
|
450 |
## OK yash STDOUT: |
451 |
# cell-unset (remove all localvar) |
452 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: local3 |
453 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: tempenv1 (unlocal 1) |
454 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: global (unlocal 2) |
455 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: (unset) (unlocal 3) |
456 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: (unset) (unlocal 4) |
457 |
## END |
458 |
|
459 |
## OK mksh STDOUT: |
460 |
# cell-unset (remove all localvar/tempenv) x tempenv-value-unset |
461 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: local3 |
462 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: tempenv1 (unlocal 1) |
463 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: (unset) (unlocal 2) |
464 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: (unset) (unlocal 3) |
465 |
[global,tempenv1/local1,tempenv2/local2,tempenv3/local3] v: (unset) (unlocal 4) |
466 |
## END |
467 |
|
468 |
|
469 |
#### [bash_unset] dynamic-unset for nested tempenvs |
470 |
unlocal() { unset -v "$1"; } |
471 |
|
472 |
f4_unlocal() { |
473 |
v=tempenv2 eval ' |
474 |
v=tempenv3 eval " |
475 |
echo \"[\$1,tempenv2,tempenv3] v: \${v-(unset)}\" |
476 |
unlocal v |
477 |
echo \"[\$1,tempenv2,tempenv3] v: \${v-(unset)} (unlocal 1)\" |
478 |
unlocal v |
479 |
echo \"[\$1,tempenv2,tempenv3] v: \${v-(unset)} (unlocal 2)\" |
480 |
unlocal v |
481 |
echo \"[\$1,tempenv2,tempenv3] v: \${v-(unset)} (unlocal 3)\" |
482 |
unlocal v |
483 |
echo \"[\$1,tempenv2,tempenv3] v: \${v-(unset)} (unlocal 4)\" |
484 |
" |
485 |
' |
486 |
} |
487 |
v=global |
488 |
v=tempenv1 f4_unlocal global,tempenv1 |
489 |
|
490 |
## STDOUT: |
491 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv3 |
492 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv2 (unlocal 1) |
493 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv1 (unlocal 2) |
494 |
[global,tempenv1,tempenv2,tempenv3] v: global (unlocal 3) |
495 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unlocal 4) |
496 |
## END |
497 |
|
498 |
## OK zsh/ash/dash/mksh STDOUT: |
499 |
# value-unset, mksh-unset |
500 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv3 |
501 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unlocal 1) |
502 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unlocal 2) |
503 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unlocal 3) |
504 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unlocal 4) |
505 |
## END |
506 |
|
507 |
## OK osh STDOUT: |
508 |
# cell-unset |
509 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv3 |
510 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv2 (unlocal 1) |
511 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv1 (unlocal 2) |
512 |
[global,tempenv1,tempenv2,tempenv3] v: global (unlocal 3) |
513 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unlocal 4) |
514 |
## END |
515 |
|
516 |
## OK yash STDOUT: |
517 |
# remove all tempenv3 |
518 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv3 |
519 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unlocal 1) |
520 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unlocal 2) |
521 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unlocal 3) |
522 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unlocal 4) |
523 |
## END |
524 |
|
525 |
#### [bash_unset] local-unset for nested tempenvs |
526 |
f4_unset() { |
527 |
v=tempenv2 eval ' |
528 |
v=tempenv3 eval " |
529 |
echo \"[\$1,tempenv2,tempenv3] v: \${v-(unset)}\" |
530 |
unset v |
531 |
echo \"[\$1,tempenv2,tempenv3] v: \${v-(unset)} (unset 1)\" |
532 |
unset v |
533 |
echo \"[\$1,tempenv2,tempenv3] v: \${v-(unset)} (unset 2)\" |
534 |
unset v |
535 |
echo \"[\$1,tempenv2,tempenv3] v: \${v-(unset)} (unset 3)\" |
536 |
unset v |
537 |
echo \"[\$1,tempenv2,tempenv3] v: \${v-(unset)} (unset 4)\" |
538 |
" |
539 |
' |
540 |
} |
541 |
v=global |
542 |
v=tempenv1 f4_unset global,tempenv1 |
543 |
|
544 |
## STDOUT: |
545 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv3 |
546 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv2 (unset 1) |
547 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv1 (unset 2) |
548 |
[global,tempenv1,tempenv2,tempenv3] v: global (unset 3) |
549 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 4) |
550 |
## END |
551 |
|
552 |
## OK zsh/ash/dash/mksh/yash STDOUT: |
553 |
# value-unset, mksh-unset, tempenv-value-unset? |
554 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv3 |
555 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 1) |
556 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 2) |
557 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 3) |
558 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 4) |
559 |
## END |
560 |
|
561 |
## OK osh STDOUT: |
562 |
# cell-unset |
563 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv3 |
564 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv2 (unset 1) |
565 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv1 (unset 2) |
566 |
[global,tempenv1,tempenv2,tempenv3] v: global (unset 3) |
567 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 4) |
568 |
## END |
569 |
|
570 |
## BUG yash STDOUT: |
571 |
# value-unset? inconsistent with other test cases |
572 |
[global,tempenv1,tempenv2,tempenv3] v: tempenv3 |
573 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 1) |
574 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 2) |
575 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 3) |
576 |
[global,tempenv1,tempenv2,tempenv3] v: (unset) (unset 4) |
577 |
## END |
578 |
|
579 |
#### [compat_array] ${arr} is ${arr[0]} |
580 |
case ${SH##*/} in (dash|ash) exit 1;; esac # dash/ash does not have arrays |
581 |
case ${SH##*/} in (osh) shopt -s compat_array;; esac |
582 |
case ${SH##*/} in (zsh) setopt KSH_ARRAYS;; esac |
583 |
arr=(foo bar baz) |
584 |
argv.py "$arr" "${arr}" |
585 |
## stdout: ['foo', 'foo'] |
586 |
|
587 |
## N-I dash/ash status: 1 |
588 |
## N-I dash/ash stdout-json: "" |
589 |
|
590 |
## OK yash stdout: ['foo', 'bar', 'baz', 'foo', 'bar', 'baz'] |
591 |
|
592 |
#### [compat_array] scalar write to arrays |
593 |
case ${SH##*/} in |
594 |
(dash|ash) exit 1;; # dash/ash does not have arrays |
595 |
(osh) shopt -s compat_array;; |
596 |
(zsh) setopt KSH_ARRAYS;; |
597 |
esac |
598 |
|
599 |
a=(1 0 0) |
600 |
: $(( a++ )) |
601 |
argv.py "${a[@]}" |
602 |
## stdout: ['2', '0', '0'] |
603 |
|
604 |
## N-I dash/ash status: 1 |
605 |
## N-I dash/ash stdout-json: "" |
606 |
|
607 |
## OK yash STDOUT: |
608 |
# yash does not support scalar access. Instead, it replaces the array |
609 |
# with a scalar. |
610 |
['1'] |
611 |
## END |
612 |
|
613 |
#### [compat_array] scalar write to associative arrays |
614 |
case ${SH##*/} in |
615 |
(dash|ash|yash|mksh) exit 1;; # dash/ash/yash/mksh does not have associative arrays |
616 |
(osh) shopt -s compat_array;; |
617 |
(zsh) setopt KSH_ARRAYS;; |
618 |
esac |
619 |
|
620 |
declare -A d=() |
621 |
d['0']=1 |
622 |
d['foo']=hello |
623 |
d['bar']=world |
624 |
((d++)) |
625 |
argv.py ${d['0']} ${d['foo']} ${d['bar']} |
626 |
## stdout: ['2', 'hello', 'world'] |
627 |
|
628 |
## N-I dash/ash/yash/mksh status: 1 |
629 |
## N-I dash/ash/yash/mksh stdout-json: "" |
630 |
|
631 |
## N-I zsh stdout: ['1', 'hello', 'world'] |
632 |
|
633 |
#### [compat_array] ${alpha@a} |
634 |
declare -A alpha=(['1']=2) |
635 |
echo type=${alpha@a} |
636 |
shopt -s compat_array |
637 |
echo type=${alpha@a} |
638 |
## STDOUT: |
639 |
type=A |
640 |
type=A |
641 |
## END |
642 |
## N-I mksh/zsh status: 1 |
643 |
## N-I dash/ash/yash status: 2 |
644 |
## N-I dash/ash/yash/mksh/zsh stdout-json: "" |