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