1 |
## compare_shells: bash mksh
|
2 |
## our_shell: -
|
3 |
|
4 |
# Corner cases for assignment that we're not handling now.
|
5 |
|
6 |
|
7 |
typeset a[3]=4 a[5]=6
|
8 |
echo status=$?
|
9 |
argv.py "${!a[@]}" "${a[@]}"
|
10 |
## STDOUT:
|
11 |
status=0
|
12 |
['3', '5', '4', '6']
|
13 |
## END
|
14 |
|
15 |
|
16 |
# declare works the same way in bash, but not mksh.
|
17 |
# spaces are NOT allowed here.
|
18 |
typeset -a a[1*1]=x a[1+2]=z
|
19 |
argv.py "${a[@]}"
|
20 |
## stdout: ['x', 'z']
|
21 |
|
22 |
|
23 |
f() {
|
24 |
local a[3]=4 a[5]=6
|
25 |
echo status=$?
|
26 |
argv.py "${!a[@]}" "${a[@]}"
|
27 |
}
|
28 |
f
|
29 |
## STDOUT:
|
30 |
status=0
|
31 |
['3', '5', '4', '6']
|
32 |
## END
|
33 |
|
34 |
|
35 |
readonly b[7]=8
|
36 |
echo status=$?
|
37 |
argv.py "${!b[@]}" "${b[@]}"
|
38 |
## STDOUT:
|
39 |
status=0
|
40 |
['7', '8']
|
41 |
## END
|
42 |
|
43 |
# bash doesn't like this variable name!
|
44 |
## N-I bash STDOUT:
|
45 |
status=1
|
46 |
[]
|
47 |
## END
|
48 |
|
49 |
|
50 |
export a[7]=8
|
51 |
echo status=$?
|
52 |
argv.py "${!a[@]}" "${a[@]}"
|
53 |
printenv.py a
|
54 |
## STDOUT:
|
55 |
status=1
|
56 |
[]
|
57 |
None
|
58 |
## END
|
59 |
## OK osh STDOUT:
|
60 |
status=2
|
61 |
[]
|
62 |
None
|
63 |
## END
|
64 |
## BUG mksh STDOUT:
|
65 |
status=0
|
66 |
['7', '8']
|
67 |
None
|
68 |
## END
|
69 |
|
70 |
|
71 |
builtin export e='E'
|
72 |
echo e=$e
|
73 |
## STDOUT:
|
74 |
e=E
|
75 |
## END
|
76 |
## N-I dash STDOUT:
|
77 |
e=
|
78 |
## END
|
79 |
|
80 |
|
81 |
readonly r1='R1' # zsh has this
|
82 |
command readonly r2='R2' # but not this
|
83 |
echo r1=$r1
|
84 |
echo r2=$r2
|
85 |
## STDOUT:
|
86 |
r1=R1
|
87 |
r2=R2
|
88 |
## END
|
89 |
## N-I zsh STDOUT:
|
90 |
r1=R1
|
91 |
r2=
|
92 |
## END
|
93 |
|
94 |
|
95 |
builtin typeset a=(1 2 3)
|
96 |
echo len=${#a[@]}
|
97 |
## stdout-json: ""
|
98 |
## status: 2
|
99 |
## OK mksh status: 1
|
100 |
|
101 |
|
102 |
command typeset a=(1 2 3)
|
103 |
echo len=${#a[@]}
|
104 |
## stdout-json: ""
|
105 |
## status: 2
|
106 |
## OK mksh status: 1
|
107 |
|