1 ## oils_failures_allowed: 3
2 ## compare_shells: bash dash mksh
3
4 #### Long Token - 65535 bytes
5
6 python2 -c 'print("echo -n %s" % ("x" * 65535))' > tmp.sh
7 $SH tmp.sh > out
8 wc --bytes out
9
10 ## STDOUT:
11 65535 out
12 ## END
13
14 #### Token that's too long for Oils - 65536 bytes
15
16 python2 -c 'print("echo -n %s" % ("x" * 65536))' > tmp.sh
17 $SH tmp.sh > out
18 echo status=$?
19 wc --bytes out
20
21 ## STDOUT:
22 status=0
23 65536 out
24 ## END
25
26 #### $% is not a parse error
27 echo $%
28 ## stdout: $%
29
30 #### Bad braced var sub -- not allowed
31 echo ${%}
32 ## status: 2
33 ## OK bash/mksh status: 1
34
35 #### Bad var sub caught at parse time
36 if test -f /; then
37 echo ${%}
38 else
39 echo ok
40 fi
41 ## status: 2
42 ## BUG dash/bash/mksh status: 0
43
44 #### Incomplete while
45 echo hi; while
46 echo status=$?
47 ## status: 2
48 ## stdout-json: ""
49 ## OK mksh status: 1
50
51 #### Incomplete for
52 echo hi; for
53 echo status=$?
54 ## status: 2
55 ## stdout-json: ""
56 ## OK mksh status: 1
57
58 #### Incomplete if
59 echo hi; if
60 echo status=$?
61 ## status: 2
62 ## stdout-json: ""
63 ## OK mksh status: 1
64
65 #### do unexpected
66 do echo hi
67 ## status: 2
68 ## stdout-json: ""
69 ## OK mksh status: 1
70
71 #### } is a parse error
72 }
73 echo should not get here
74 ## stdout-json: ""
75 ## status: 2
76 ## OK mksh status: 1
77
78 #### { is its own word, needs a space
79 # bash and mksh give parse time error because of }
80 # dash gives 127 as runtime error
81 {ls; }
82 echo "status=$?"
83 ## stdout-json: ""
84 ## status: 2
85 ## OK mksh status: 1
86
87 #### } on the second line
88 set -o errexit
89 {ls;
90 }
91 ## status: 127
92
93 #### Invalid for loop variable name
94 for i.j in a b c; do
95 echo hi
96 done
97 echo done
98 ## stdout-json: ""
99 ## status: 2
100 ## OK mksh status: 1
101 ## BUG bash status: 0
102 ## BUG bash stdout: done
103
104 #### bad var name globally isn't parsed like an assignment
105 # bash and dash disagree on exit code.
106 FOO-BAR=foo
107 ## status: 127
108
109 #### bad var name in export
110 # bash and dash disagree on exit code.
111 export FOO-BAR=foo
112 ## status: 1
113 ## OK dash status: 2
114
115 #### bad var name in local
116 # bash and dash disagree on exit code.
117 f() {
118 local FOO-BAR=foo
119 }
120 f
121 ## status: 1
122 ## OK dash status: 2
123
124 #### misplaced parentheses are not a subshell
125 echo a(b)
126 ## status: 2
127 ## OK mksh status: 1
128
129 #### incomplete command sub
130 $(x
131 ## status: 2
132 ## OK mksh status: 1
133
134 #### incomplete backticks
135 `x
136 ## status: 2
137 ## OK mksh status: 1
138
139 #### misplaced ;;
140 echo 1 ;; echo 2
141 ## stdout-json: ""
142 ## status: 2
143 ## OK mksh status: 1
144
145 #### empty clause in [[
146
147 # regression test for commit 451ca9e2b437e0326fc8155783d970a6f32729d8
148 [[ || true ]]
149
150 ## status: 2
151 ## N-I dash status: 0
152 ## OK mksh status: 1
153
154 #### interactive parse error (regression)
155 flags=''
156 case $SH in
157 bash*|*osh)
158 flags='--rcfile /dev/null'
159 ;;
160 esac
161 $SH $flags -i -c 'var=)'
162
163 ## status: 2
164 ## OK mksh status: 1
165
166 #### array literal inside array is a parse error
167 a=( inside=() )
168 echo len=${#a[@]}
169 ## status: 2
170 ## stdout-json: ""
171 ## OK mksh status: 1
172 ## BUG bash status: 0
173 ## BUG bash stdout: len=0
174
175 #### array literal inside loop is a parse error
176 f() {
177 for x in a=(); do
178 echo x=$x
179 done
180 echo done
181 }
182 f
183 ## status: 2
184 ## stdout-json: ""
185 ## OK mksh status: 1
186
187 #### array literal in case
188 f() {
189 case a=() in
190 foo)
191 echo hi
192 ;;
193 esac
194 }
195 f
196 ## status: 2
197 ## stdout-json: ""
198 ## OK mksh status: 1
199
200 #### %foo=() is parse error (regression)
201
202 # Lit_VarLike and then (, but NOT at the beginning of a word.
203
204 f() {
205 %foo=()
206 }
207 ## status: 2
208 ## stdout-json: ""
209 ## OK mksh status: 1
210
211 #### echo =word is allowed
212 echo =word
213 ## STDOUT:
214 =word
215 ## END