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 |
|
160 | #### interactive parse error (regression)
|
161 | flags=''
|
162 | case $SH in
|
163 | bash*|*osh)
|
164 | flags='--rcfile /dev/null'
|
165 | ;;
|
166 | esac
|
167 | $SH $flags -i -c 'var=)'
|
168 |
|
169 | ## status: 2
|
170 | ## OK mksh status: 1
|
171 |
|
172 | #### array literal inside array is a parse error
|
173 | a=( inside=() )
|
174 | echo len=${#a[@]}
|
175 | ## status: 2
|
176 | ## stdout-json: ""
|
177 | ## OK mksh status: 1
|
178 | ## BUG bash status: 0
|
179 | ## BUG bash stdout: len=0
|
180 |
|
181 | #### array literal inside loop is a parse error
|
182 | f() {
|
183 | for x in a=(); do
|
184 | echo x=$x
|
185 | done
|
186 | echo done
|
187 | }
|
188 | f
|
189 | ## status: 2
|
190 | ## stdout-json: ""
|
191 | ## OK mksh status: 1
|
192 |
|
193 | #### array literal in case
|
194 | f() {
|
195 | case a=() in
|
196 | foo)
|
197 | echo hi
|
198 | ;;
|
199 | esac
|
200 | }
|
201 | f
|
202 | ## status: 2
|
203 | ## stdout-json: ""
|
204 | ## OK mksh status: 1
|
205 |
|
206 | #### %foo=() is parse error (regression)
|
207 |
|
208 | # Lit_VarLike and then (, but NOT at the beginning of a word.
|
209 |
|
210 | f() {
|
211 | %foo=()
|
212 | }
|
213 | ## status: 2
|
214 | ## stdout-json: ""
|
215 | ## OK mksh status: 1
|
216 |
|
217 | #### leading =word is not allowed regardless of shopt -s parse_equals
|
218 | =word
|
219 | ## OK osh status: 2
|
220 | ## status: 127
|
221 |
|
222 | #### echo =word is allowed
|
223 | echo =word
|
224 | ## STDOUT:
|
225 | =word
|
226 | ## END
|