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