t_syntax.sh revision 1.8 1 1.8 kre # $NetBSD: t_syntax.sh,v 1.8 2017/08/19 21:18:47 kre Exp $
2 1.1 kre #
3 1.1 kre # Copyright (c) 2017 The NetBSD Foundation, Inc.
4 1.1 kre # All rights reserved.
5 1.1 kre #
6 1.1 kre # Redistribution and use in source and binary forms, with or without
7 1.1 kre # modification, are permitted provided that the following conditions
8 1.1 kre # are met:
9 1.1 kre # 1. Redistributions of source code must retain the above copyright
10 1.1 kre # notice, this list of conditions and the following disclaimer.
11 1.1 kre # 2. Redistributions in binary form must reproduce the above copyright
12 1.1 kre # notice, this list of conditions and the following disclaimer in the
13 1.1 kre # documentation and/or other materials provided with the distribution.
14 1.1 kre #
15 1.1 kre # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1 kre # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1 kre # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1 kre # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1 kre # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1 kre # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1 kre # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1 kre # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1 kre # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1 kre # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 kre # POSSIBILITY OF SUCH DAMAGE.
26 1.1 kre #
27 1.1 kre : ${TEST_SH:=/bin/sh}
28 1.1 kre
29 1.1 kre # This set of tests verifies various requirementgs relating to correct
30 1.1 kre # (and incorrect) syntax of shell input
31 1.1 kre #
32 1.1 kre # There is no intent in these tests to verify correct operation
33 1.1 kre # (though that sometimes cannot be separated from correct parsing.)
34 1.1 kre # That is (or should be) verified elsewhere.
35 1.1 kre #
36 1.1 kre # Also, some very basic syntax is tested in almost every test
37 1.1 kre # (they cannot work without basic parsing of elementary commands)
38 1.1 kre # so that is also not explicitly tested here.
39 1.1 kre #
40 1.1 kre # Similarly word expansion, field splitting, redirection, all have
41 1.1 kre # tests of their own (though we do test parsing of redirect ops).
42 1.1 kre #
43 1.1 kre # Note that in order to test the basic facilities, other shell operations
44 1.1 kre # are used - a test failure here does not necessarily mean that the
45 1.1 kre # operation intended to be tested is faulty, just that something is.
46 1.1 kre
47 1.1 kre atf_test_case a_basic_tokenisation
48 1.1 kre a_basic_tokenisation_head() {
49 1.1 kre atf_set "descr" "Test the shell correctly finds various tokens"
50 1.1 kre }
51 1.1 kre a_basic_tokenisation_body() {
52 1.1 kre atf_check -s exit:0 -o 'inline:3\n' -e empty ${TEST_SH} -c \
53 1.1 kre 'set -- a b c; echo $#'
54 1.1 kre atf_check -s exit:0 -o 'inline:2\n' -e empty ${TEST_SH} -c \
55 1.1 kre 'set -- a""b c; echo $#'
56 1.1 kre atf_check -s exit:0 -o 'inline:3\n' -e empty ${TEST_SH} -c \
57 1.1 kre 'set -- a"" b c; echo $#'
58 1.1 kre atf_check -s exit:0 -o 'inline:3\n' -e empty ${TEST_SH} -c \
59 1.1 kre 'set -- ""a b c\;; echo $#'
60 1.1 kre
61 1.1 kre atf_check -s exit:0 -o 'inline:3\n' -e empty ${TEST_SH} -c \
62 1.1 kre 'set -- set -- c; echo $#'
63 1.1 kre atf_check -s exit:0 -o 'inline:1\n' -e empty ${TEST_SH} -c \
64 1.1 kre 'set --;set -- c; echo $#'
65 1.1 kre atf_check -s exit:0 -o 'inline:1\n' -e empty ${TEST_SH} -c \
66 1.1 kre 'set --&set -- c; echo $#'
67 1.1 kre atf_check -s exit:0 -o 'inline:1\n' -e empty ${TEST_SH} -c \
68 1.1 kre 'set -- a b&&set -- c; echo $#'
69 1.1 kre atf_check -s exit:0 -o 'inline:2\n' -e empty ${TEST_SH} -c \
70 1.1 kre 'set -- a b||set -- c; echo $#'
71 1.1 kre }
72 1.1 kre
73 1.1 kre atf_test_case b_comments
74 1.1 kre b_comments_head() {
75 1.1 kre atf_set "descr" "Test the shell correctly handles comments"
76 1.1 kre }
77 1.1 kre b_comments_body() {
78 1.1 kre
79 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c '#'
80 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c '# exit 1'
81 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c 'true # exit 1'
82 1.1 kre atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c 'false # exit 0'
83 1.1 kre
84 1.1 kre atf_check -s exit:0 -o 'inline:foo\n' -e empty ${TEST_SH} -c \
85 1.1 kre 'echo foo # bar'
86 1.1 kre atf_check -s exit:0 -o 'inline:foo # bar\n' -e empty ${TEST_SH} -c \
87 1.1 kre 'echo foo \# bar'
88 1.1 kre atf_check -s exit:0 -o 'inline:foo\n' -e empty ${TEST_SH} -c \
89 1.1 kre 'echo foo; # echo bar'
90 1.1 kre atf_check -s exit:0 -o 'inline:foo#bar\n' -e empty ${TEST_SH} -c \
91 1.1 kre 'echo foo#bar'
92 1.1 kre atf_check -s exit:0 -o 'inline:foo# bar\n' -e empty ${TEST_SH} -c \
93 1.1 kre 'echo foo# bar'
94 1.1 kre atf_check -s exit:0 -o 'inline:foo\n' -e empty ${TEST_SH} -c \
95 1.1 kre 'x=foo; echo ${x#bar}'
96 1.1 kre
97 1.1 kre atf_check -s exit:0 -o 'inline:#\n' -e empty ${TEST_SH} -c \
98 1.1 kre 'echo "#"'
99 1.1 kre atf_check -s exit:0 -o 'inline:#\n' -e empty ${TEST_SH} -c \
100 1.1 kre "echo '#'"
101 1.1 kre atf_check -s exit:0 -o 'inline:#\n' -e empty ${TEST_SH} -c \
102 1.1 kre 'echo \#'
103 1.1 kre atf_check -s exit:0 -o 'inline:##\n' -e empty ${TEST_SH} -c \
104 1.1 kre 'echo "#"#'
105 1.1 kre atf_check -s exit:0 -o 'inline:##\n' -e empty ${TEST_SH} -c \
106 1.1 kre "echo '#'#"
107 1.1 kre atf_check -s exit:0 -o 'inline:##\n' -e empty ${TEST_SH} -c \
108 1.1 kre 'echo \##'
109 1.1 kre atf_check -s exit:0 -o 'inline:##\n' -e empty ${TEST_SH} -c \
110 1.1 kre 'echo "#"# #"#"'
111 1.1 kre atf_check -s exit:0 -o 'inline:##\n' -e empty ${TEST_SH} -c \
112 1.1 kre "echo '#'# #'#'"
113 1.1 kre atf_check -s exit:0 -o 'inline:##\n' -e empty ${TEST_SH} -c \
114 1.1 kre 'echo \## #\#'
115 1.1 kre
116 1.1 kre cat <<-'DONE'|atf_check -s exit:0 -o inline:'foo\n' -e empty ${TEST_SH}
117 1.1 kre # test comments do not provoke synax errors !\
118 1.1 kre echo foo # ( { " hello
119 1.1 kre while : # that's forever
120 1.1 kre do # the following command list
121 1.1 kre # starting with nothing ${unset?error}
122 1.1 kre break # done loop terminate $( echo bar; exit 1 )
123 1.1 kre done #####################################################
124 1.1 kre # "hello
125 1.1 kre exit 0
126 1.1 kre DONE
127 1.1 kre }
128 1.1 kre
129 1.1 kre atf_test_case c_line_wrapping
130 1.1 kre c_line_wrapping_head() {
131 1.1 kre atf_set "descr" "check aspects of command line wrapping"
132 1.1 kre }
133 1.1 kre c_line_wrapping_body() {
134 1.1 kre atf_require_prog ls
135 1.1 kre atf_require_prog printf
136 1.1 kre
137 1.1 kre cat <<- 'DONE' | atf_check -s exit:0 -o ignore -e empty ${TEST_SH} -e
138 1.1 kre l\
139 1.1 kre s
140 1.1 kre DONE
141 1.1 kre
142 1.1 kre cat <<- 'DONE' | atf_check -s exit:7 -o empty -e empty ${TEST_SH}
143 1.1 kre e\
144 1.1 kre x\
145 1.1 kre it \
146 1.1 kre 7
147 1.1 kre DONE
148 1.1 kre
149 1.1 kre # Have to do this twice as cannot say "any exit code but 0 or 7" ...
150 1.1 kre cat <<- 'DONE' | atf_check -s not-exit:0 -o empty -e not-empty \
151 1.1 kre ${TEST_SH}
152 1.1 kre e\
153 1.1 kre x\
154 1.1 kre it\
155 1.1 kre 7
156 1.1 kre DONE
157 1.1 kre cat <<- 'DONE' | atf_check -s not-exit:7 -o empty -e not-empty \
158 1.1 kre ${TEST_SH}
159 1.1 kre e\
160 1.1 kre x\
161 1.1 kre it\
162 1.1 kre 7
163 1.1 kre DONE
164 1.1 kre
165 1.1 kre cat <<- 'DONE' | atf_check -s exit:0 -o empty -e empty ${TEST_SH}
166 1.1 kre wh\
167 1.1 kre il\
168 1.1 kre e \
169 1.1 kre f\a\
170 1.1 kre \l\s\e
171 1.1 kre do
172 1.1 kre :\
173 1.1 kre ;
174 1.1 kre done
175 1.1 kre DONE
176 1.1 kre
177 1.1 kre cat <<- 'DONE' | atf_check -s exit:0 -o inline:'hellohellohellohello' \
178 1.1 kre -e empty ${TEST_SH}
179 1.1 kre V\
180 1.1 kre AR=hel\
181 1.1 kre lo
182 1.1 kre unset U V1
183 1.1 kre pri\
184 1.1 kre ntf '%s' ${\
185 1.1 kre VAR\
186 1.1 kre }
187 1.1 kre p\
188 1.1 kre r\
189 1.1 kre i\
190 1.1 kre n\
191 1.1 kre t\
192 1.1 kre f\
193 1.1 kre \
194 1.1 kre '%s' \
195 1.1 kre $\
196 1.1 kre {\
197 1.1 kre V\
198 1.1 kre A\
199 1.1 kre R}
200 1.1 kre printf '%s' ${U\
201 1.1 kre -\
202 1.1 kre "$\
203 1.1 kre {V\
204 1.1 kre 1:\
205 1.1 kre =$\
206 1.1 kre {V\
207 1.1 kre AR+\
208 1.1 kre ${V\
209 1.1 kre AR}\
210 1.1 kre }\
211 1.3 kre }"}
212 1.1 kre printf '%s' ${V\
213 1.1 kre 1?V1\
214 1.1 kre \
215 1.1 kre FAIL}
216 1.1 kre DONE
217 1.3 kre
218 1.1 kre cat <<- 'DONE' | atf_check -s exit:0 -o inline:'2\n' ${TEST_SH}
219 1.1 kre l\
220 1.1 kre s=7 bi\
221 1.1 kre n\
222 1.1 kre =\
223 1.1 kre 3
224 1.1 kre echo $(\
225 1.1 kre ( ls /bin )\
226 1.1 kre )
227 1.1 kre DONE
228 1.3 kre
229 1.3 kre # Inspired by src/etc/MAKEDEV.tmpl failure with (broken)
230 1.3 kre # sh LINENO code... avoid it happening again...
231 1.3 kre for VARS in 1:0:0:0 0:1:0:0 0:0:1:0 0:0:0:1 \
232 1.3 kre 1:0:0:1 1:0:1:0 1:1:0:0 0:1:1:0 \
233 1.3 kre 0:0:0:0 1:1:0:1 0:1:1:1 1:1:1:1
234 1.3 kre do
235 1.3 kre eval $(
236 1.3 kre IFS=:
237 1.3 kre set -- $VARS
238 1.3 kre test $(( $1 + $2 + $3 + $4 )) -eq 1 &&
239 1.3 kre R=OK || R=BAD
240 1.3 kre printf "R=%s;" $R
241 1.3 kre for v in a b c d
242 1.3 kre do
243 1.3 kre case $1 in
244 1.3 kre (0) printf "export %s=false;" $v;;
245 1.3 kre (1) printf "export %s=true;" $v;;
246 1.3 kre esac
247 1.3 kre shift
248 1.3 kre done
249 1.3 kre )
250 1.3 kre
251 1.3 kre cat <<- 'DONE' | atf_check -s exit:0 -o inline:"${R}" ${TEST_SH}
252 1.3 kre case $(( $($a && echo 1 || echo 0) + \
253 1.3 kre $($b && echo 1 || echo 0) + \
254 1.3 kre $($c && echo 1 || echo 0) + \
255 1.3 kre $($d && echo 1 || echo 0) ))
256 1.3 kre in
257 1.3 kre (1) printf OK ;;
258 1.3 kre (*) printf BAD ;;
259 1.3 kre esac
260 1.3 kre DONE
261 1.3 kre done
262 1.3 kre
263 1.3 kre # inspired by pkgsrc/pkgtools/cwrappers :: libnbcompat/configure
264 1.7 kre # failure with (broken) sh LINENO code .. avoid recurrence
265 1.3 kre # This test would have failed.
266 1.3 kre cat <<- 'DONE' | atf_check -s exit:0 -o inline:'/tmp\n' ${TEST_SH}
267 1.3 kre dn=/tmp/foo
268 1.3 kre
269 1.3 kre D=`dirname -- "${dn}" ||
270 1.3 kre expr X"${dn}" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
271 1.3 kre X"${dn}" : 'X\(//\)[^/]' \| \
272 1.3 kre X"${dn}" : 'X\(//\)$' \| \
273 1.3 kre X"${dn}" : 'X\(/\)' \| . 2>/dev/null ||
274 1.3 kre echo X"${dn}" |
275 1.3 kre sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
276 1.3 kre s//\1/
277 1.3 kre q
278 1.3 kre }
279 1.3 kre /^X\(\/\/\)[^/].*/{
280 1.3 kre s//\1/
281 1.3 kre q
282 1.3 kre }
283 1.3 kre /^X\(\/\/\)$/{
284 1.3 kre s//\1/
285 1.3 kre q
286 1.3 kre }
287 1.3 kre /^X\(\/\).*/{
288 1.3 kre s//\1/
289 1.3 kre q
290 1.3 kre }
291 1.3 kre s/.*/./; q'`
292 1.3 kre
293 1.3 kre echo "${D}"
294 1.3 kre DONE
295 1.3 kre return 0
296 1.1 kre }
297 1.1 kre
298 1.7 kre atf_test_case d_cstrings
299 1.7 kre d_cstrings_head() {
300 1.7 kre atf_set "descr" "Check processing of $' ' quoting (C style strings)"
301 1.7 kre }
302 1.7 kre d_cstrings_body() {
303 1.7 kre unset ENV
304 1.8 kre
305 1.7 kre if ! ${TEST_SH} -c ": \$'abc'" ||
306 1.7 kre test $( ${TEST_SH} -c "printf %s \$'abc'" ) != abc
307 1.7 kre then
308 1.7 kre atf_skip "\$'...' (C style quoted strings) not supported"
309 1.7 kre fi
310 1.7 kre
311 1.7 kre # simple stuff
312 1.7 kre atf_check -s exit:0 -e empty -o inline:'abc\tdef\n' ${TEST_SH} -c \
313 1.7 kre "printf '%s\\n' \$'abc\tdef'"
314 1.7 kre atf_check -s exit:0 -e empty -o inline:'abc\tdef\n' ${TEST_SH} -c \
315 1.7 kre "printf '%s\\n' \$'abc\011def'"
316 1.7 kre atf_check -s exit:0 -e empty -o inline:'abc\tdef\n' ${TEST_SH} -c \
317 1.7 kre "printf '%s\\n' \$'abc\x09'def"
318 1.7 kre atf_check -s exit:0 -e empty -o inline:'abc$def\n' ${TEST_SH} -c \
319 1.7 kre "def=xyz; printf '%s\\n' \$'abc\$def'"
320 1.7 kre
321 1.7 kre # control chars (\c) and unicode \u
322 1.7 kre atf_check -s exit:0 -e empty -o empty ${TEST_SH} -c \
323 1.7 kre "test \$'\\1-\\2-\\3' = \$'\\ca-\\cb-\\cc'"
324 1.7 kre atf_check -s exit:0 -e empty -o empty ${TEST_SH} -c \
325 1.7 kre "test \$'\\r-\\n-\\f' = \$'\\cm-\\cj-\\cl'"
326 1.7 kre atf_check -s exit:0 -e empty -o empty ${TEST_SH} -c \
327 1.7 kre "test \$'\\u0123' = \$'\\304\\243'"
328 1.7 kre atf_check -s exit:0 -e empty -o empty ${TEST_SH} -c \
329 1.7 kre "test \$'\\u0123' = \$'\\xC4\\xA3'"
330 1.7 kre atf_check -s exit:0 -e empty -o empty ${TEST_SH} -c \
331 1.7 kre "test \$'\\c\\\\' = \$'\\x1C'"
332 1.7 kre atf_check -s exit:0 -e empty -o empty ${TEST_SH} -c \
333 1.7 kre "test \$'\\c[\\c]\\c^\\c_\\c?' = \$'\\x1B\\x1D\\x1E\\x1F\\x7F'"
334 1.7 kre
335 1.7 kre # all the \X sequences for a single char X (ie: not hex/octal/unicode)
336 1.7 kre atf_check -s exit:0 -e empty -o inline:'\n\r\t\n' \
339 1.7 kre ${TEST_SH} -c "printf '%s\\n' \$'\\a\\b\\e\\f\\n\\r\\t\\v'"
340 1.7 kre atf_check -s exit:0 -e empty -o inline:'\n\r\t\n' \
343 1.7 kre ${TEST_SH} -c "printf '%s\\n' \$'\\cG\\cH\\x1b\\cl\\cJ\\cm\\cI\\ck'"
344 1.7 kre atf_check -s exit:0 -e empty -o inline:"'"'"\\\n' \
345 1.7 kre ${TEST_SH} -c "printf '%s\\n' \$'\\'\\\"\\\\'"
346 1.7 kre
347 1.7 kre # various invalid $'...' sequences
348 1.7 kre atf_check -s not-exit:0 -e not-empty -o ignore ${TEST_SH} -c \
349 1.7 kre ": \$'\\q'"
350 1.7 kre atf_check -s not-exit:0 -e not-empty -o ignore ${TEST_SH} -c \
351 1.7 kre ": \$'\\c\\q'"
352 1.7 kre atf_check -s not-exit:0 -e not-empty -o ignore ${TEST_SH} -c \
353 1.7 kre ": \$'\\uDEFF'"
354 1.7 kre atf_check -s not-exit:0 -e not-empty -o ignore ${TEST_SH} -c \
355 1.7 kre ": \$'\\u00'"
356 1.7 kre atf_check -s not-exit:0 -e not-empty -o ignore ${TEST_SH} -c \
357 1.7 kre ": \$'\\u8'"
358 1.7 kre atf_check -s not-exit:0 -e not-empty -o ignore ${TEST_SH} -c \
359 1.7 kre ": \$'abcd"
360 1.7 kre atf_check -s not-exit:0 -e not-empty -o ignore ${TEST_SH} -c \
361 1.7 kre ": \$'abcd\\"
362 1.7 kre
363 1.7 kre # anything that generates \0 ends the $'...' immediately (\u cannot)
364 1.7 kre atf_check -s exit:0 -e empty -o inline:'aAa' ${TEST_SH} -c \
365 1.8 kre "printf '%s' \$'a\\0x'\$'A\\x00X'\$'a\\c@x'"
366 1.8 kre
367 1.8 kre # \newline in a $'...' is dropped (just like in "" strings)
368 1.8 kre atf_check -s exit:0 -e empty -o inline:'abcdef' ${TEST_SH} -c \
369 1.8 kre "printf '%s' \$'abc\\
370 1.7 kre def'"
371 1.8 kre # but a normal newline in a $'...' is just a newline
372 1.8 kre atf_check -s exit:0 -e empty -o inline:'abc\ndef' ${TEST_SH} -c \
373 1.8 kre "printf '%s' \$'abc
374 1.8 kre def'"
375 1.8 kre # and should work when elided line wrap occurs between $ and '
376 1.8 kre atf_check -s exit:0 -e empty -o inline:'abc\ndef' ${TEST_SH} -c \
377 1.8 kre "printf '%s' \$\\
378 1.8 kre 'abc\\ndef'"
379 1.8 kre
380 1.8 kre # $'...' only works when the $ is unquoted.
381 1.8 kre atf_check -s exit:0 -e empty -o inline:"abc\$'def'g" ${TEST_SH} -c \
382 1.8 kre "printf '%s' \"abc\$'def'g\""
383 1.7 kre atf_check -s exit:0 -e empty -o inline:'abc$defg' ${TEST_SH} -c \
384 1.7 kre "printf '%s' abc\\\$'def'g"
385 1.7 kre atf_check -s exit:0 -e empty -o inline:'abc$def' ${TEST_SH} -c \
386 1.7 kre "printf '%s' abc'\$'def"
387 1.1 kre }
388 1.1 kre
389 1.7 kre atf_test_case f_redirects
390 1.1 kre f_redirects_head() {
391 1.1 kre atf_set "descr" "Check parsing of redirect operators"
392 1.1 kre }
393 1.1 kre f_redirects_body() {
394 1.1 kre
395 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
396 1.1 kre '>/dev/null'
397 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
398 1.1 kre '</dev/null'
399 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
400 1.1 kre '>>/dev/null'
401 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
402 1.1 kre '<>/dev/null'
403 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
404 1.1 kre '</dev/null>/dev/null'
405 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
406 1.4 kre '>|/dev/null'
407 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
408 1.4 kre '>/dev/null>/dev/null>/dev/null'
409 1.1 kre
410 1.4 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
411 1.1 kre 'echo hello >/dev/null'
412 1.4 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
413 1.1 kre 'echo >/dev/null hello'
414 1.4 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
415 1.1 kre '>/dev/null echo hello'
416 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
417 1.4 kre 'echo hello >/dev/null world'
418 1.1 kre atf_check -s exit:0 -o 'inline:hello world\n' -e empty ${TEST_SH} -c \
419 1.4 kre 'echo hello </dev/null world'
420 1.1 kre
421 1.4 kre atf_check -s exit:0 -o 'inline:hello\n' -e empty ${TEST_SH} -c \
422 1.1 kre 'echo hello </dev/null'
423 1.4 kre atf_check -s exit:0 -o 'inline:hello\n' -e empty ${TEST_SH} -c \
424 1.1 kre 'echo hello 3</dev/null'
425 1.4 kre atf_check -s exit:0 -o 'inline:hello 3\n' -e empty ${TEST_SH} -c \
426 1.1 kre 'echo hello 3 </dev/null'
427 1.4 kre atf_check -s exit:0 -o 'inline:hello 3\n' -e empty ${TEST_SH} -c \
428 1.1 kre 'echo hello \3</dev/null'
429 1.1 kre atf_check -s exit:0 -o 'inline:hello\n' -e empty ${TEST_SH} -c \
430 1.4 kre 'echo hello</dev/null'
431 1.1 kre atf_check -s exit:0 -o 'inline:3\n' -e empty ${TEST_SH} -c \
432 1.4 kre 'hello=3; echo ${hello}</dev/null'
433 1.1 kre
434 1.4 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
435 1.1 kre '2>&1'
436 1.4 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
437 1.1 kre '2>& 1'
438 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
439 1.4 kre 'FD=1; 2>&"${FD}"'
440 1.1 kre atf_check -s exit:0 -o 'inline:hello\n' -e empty ${TEST_SH} -c \
441 1.1 kre 'FD=1; echo hello 2>&"${FD}" >&2'
442 1.1 kre
443 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
444 1.1 kre '2>&- 3<&- 4>&-'
445 1.7 kre
446 1.7 kre return 0
447 1.1 kre }
448 1.1 kre
449 1.7 kre atf_test_case g_variable_syntax
450 1.1 kre g_variable_syntax_head() {
451 1.1 kre atf_set "descr" "Check that var names of all legal forms work"
452 1.1 kre }
453 1.1 kre g_variable_syntax_body() {
454 1.5 kre # don't test _ as a variable, it can be "unusual"
455 1.5 kre for vname in a ab _a _9 a123 a_1_2_3 __ ___ ____ __1__ _0 \
456 1.5 kre A AA AAA AaBb _A_a A_a_ a1_ abc_123 ab_12_cd_ef_34_99 \
457 1.1 kre abcdefghijklmnopqrstuvwzyz ABCDEFGHIJKLMNOPQRSTUVWXYZ_ \
458 1.1 kre A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all \
459 1.1 kre Then_Make_it_Even_Longer_by_Multiplying_it___A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all__A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all__A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all__A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all \
460 1.1 kre xyzzy __0123454321__ _0_1_2_3_4_5_6_7_8_9_ ABBA X_ Y__ Z___ \
461 1.1 kre _____________________________________________________________
462 1.1 kre do
463 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
464 1.1 kre "unset ${vname}"
465 1.1 kre atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -c \
466 1.1 kre "unset ${vname}; printf %s \${${vname}-OK}"
467 1.1 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
468 1.1 kre "${vname}=GOOD; printf %s \${${vname}-OK}"
469 1.1 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
470 1.1 kre "${vname}=GOOD; printf %s \$${vname}"
471 1.1 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
472 1.1 kre "unset ${vname};${vname}=GOOD;printf %s \${${vname}-OK}"
473 1.1 kre atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -c \
474 1.1 kre "${vname}=GOOD;unset ${vname};printf %s \${${vname}-OK}"
475 1.5 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
476 1.5 kre "${vname}=GOOD; unset ${vname}x; printf %s \$${vname}"
477 1.5 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
478 1.5 kre "unset ${vname}x; ${vname}=GOOD; printf %s \$${vname}x"
479 1.5 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
480 1.5 kre "${vname}=GOOD; ${vname}_=BAD; printf %s \$${vname}"
481 1.5 kre
482 1.5 kre case "${vname}" in
483 1.5 kre ?) continue;;
484 1.5 kre esac
485 1.5 kre
486 1.5 kre # The following tests do not work for 1 char var names.
487 1.5 kre # hence the check and "continue" above to skip the remaining
488 1.5 kre # tests for that case
489 1.5 kre
490 1.5 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
491 1.5 kre "${vname}=GOOD; unset ${vname%?}; printf %s \$${vname}"
492 1.5 kre
493 1.5 kre # (this next would work, but becomes just a duplicate of
494 1.5 kre # an earlier test, so is pointless for 1 ch names)
495 1.5 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
496 1.5 kre "${vname}=GOOD; unset ${vname}x ${vname%?}; printf %s \$${vname}"
497 1.5 kre
498 1.5 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
499 1.5 kre "unset ${vname%?};${vname}=GOOD; printf %s \$${vname%?}"
500 1.5 kre
501 1.5 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
502 1.5 kre "${vname}=GOOD; ${vname%?}=BAD; printf %s \$${vname}"
503 1.5 kre
504 1.5 kre # all the remaining tests require the 2nd char of the
505 1.5 kre # variable name to be a legal first character. That
506 1.5 kre # is, not a digit, so skip the rest if we have a digit
507 1.5 kre # second...
508 1.5 kre case "${vname}" in
509 1.5 kre ?[0-9]*) continue;;
510 1.5 kre esac
511 1.5 kre
512 1.5 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
513 1.5 kre "${vname}=GOOD; unset ${vname#?}; printf %s \$${vname}"
514 1.5 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
515 1.5 kre "unset ${vname#?};${vname}=GOOD; printf %s \$${vname#?}"
516 1.5 kre
517 1.5 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
518 1.5 kre "${vname}=GOOD; ${vname#?}=BAD; printf %s \$${vname}"
519 1.5 kre
520 1.5 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
521 1.5 kre "unset ${vname%?} ${vname#?} ${vname}x; ${vname}=GOOD;
522 1.5 kre printf %s \$${vname%?}\$${vname#?}\$${vname}x"
523 1.1 kre
524 1.1 kre atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
525 1.1 kre "${vname}=GOOD; ${vname%?}=BAD; ${vname}_=BAD;
526 1.1 kre ${vname#?}=BAD; printf %s \$${vname}"
527 1.1 kre done
528 1.1 kre
529 1.1 kre # don't test '.' in var names, some shells permit that (in ${} anyway)
530 1.1 kre # this test also cannot check for embedded - + ? = : % or #
531 1.1 kre for vname in ,x -p +h :def 0_1 'x*x' '()' '"' "'" 'a b c' '?!' ';'
532 1.1 kre do
533 1.1 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
534 1.1 kre "echo \${${vname}}"
535 1.1 kre done
536 1.1 kre
537 1.1 kre for vname in ,x -p +h :def 0_1 'x*x' '()' '"' "'" 'a b c' x,y,z '?!' \
538 1.1 kre ';' a-b a+b 'a?b' 'a:b' 'a%b' 'a#b' 0 1 99 @ '*' '!' '?'
539 1.1 kre do
540 1.1 kre # failure modes will differ, but they should all fail somehow
541 1.1 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
542 1.1 kre "${vname}="
543 1.7 kre done
544 1.7 kre
545 1.1 kre }
546 1.1 kre
547 1.7 kre atf_test_case h_var_assign
548 1.1 kre h_var_assign_head() {
549 1.1 kre atf_set "descr" "Check var assignments "
550 1.1 kre }
551 1.1 kre h_var_assign_body() {
552 1.1 kre atf_check -s exit:0 -e empty -o empty ${TEST_SH} -c \
553 1.1 kre 'a=b'
554 1.1 kre atf_check -s not-exit:0 -e not-empty -o empty ${TEST_SH} -c \
555 1.1 kre '\a=b'
556 1.1 kre atf_check -s exit:0 -e empty -o empty ${TEST_SH} -c \
557 1.1 kre 'a=b c=d'
558 1.1 kre atf_check -s exit:0 -e empty -o 'inline:e=f\n' ${TEST_SH} -c \
559 1.1 kre 'a=b c=d echo e=f'
560 1.1 kre atf_check -s exit:0 -e empty -o 'inline:e=f\n' ${TEST_SH} -c \
561 1.1 kre 'a=b 2>/dev/null c=d </dev/null echo e=f'
562 1.1 kre
563 1.1 kre # We need to make sure that we do not accidentally
564 1.1 kre # find a command called 'a=b' ...
565 1.1 kre
566 1.1 kre for d in /foo /foo/bar /not-dir /no/such/directory '/!!!' \
567 1.1 kre '/-/--/#' '/"/""/"""' -
568 1.1 kre do
569 1.1 kre test -d "${d}" || break
570 1.1 kre done
571 1.1 kre test "${#d}" -gt 1 || atf-skip 'Wacky directories seem to exist!'
572 1.1 kre
573 1.1 kre atf_check -s exit:0 -e empty -o empty ${TEST_SH} -c \
574 1.1 kre "PATH='${d}';"'a=\b'
575 1.1 kre atf_check -s not-exit:0 -e not-empty -o empty ${TEST_SH} -c \
576 1.1 kre "PATH='${d}';"'a\=b'
577 1.1 kre atf_check -s not-exit:0 -e not-empty -o empty ${TEST_SH} -c \
578 1.1 kre "PATH='${d}';"'\a=b'
579 1.1 kre atf_check -s not-exit:0 -e not-empty -o empty ${TEST_SH} -c \
580 1.1 kre "PATH='${d}';"'X=; c=d ${X} a=b'
581 1.1 kre }
582 1.1 kre
583 1.1 kre atf_test_case i_pipelines
584 1.1 kre i_pipelines_head() {
585 1.1 kre atf_set "descr" "Check pipelines"
586 1.1 kre }
587 1.1 kre i_pipelines_body() {
588 1.1 kre
589 1.1 kre cmd='printf "%s\n" foo'
590 1.1 kre for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
591 1.1 kre do
592 1.1 kre atf_check -s exit:0 -o inline:'foo\n' -e empty ${TEST_SH} -c \
593 1.1 kre "${cmd}"
594 1.1 kre cmd="${cmd} | cat"
595 1.1 kre done
596 1.1 kre
597 1.1 kre cmd='printf "%s\n" foo'
598 1.1 kre for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
599 1.1 kre do
600 1.1 kre atf_check -s exit:0 -o inline:'foo\n' -e empty ${TEST_SH} -c \
601 1.1 kre "${cmd}"
602 1.1 kre cmd="${cmd} |
603 1.1 kre cat"
604 1.1 kre done
605 1.1 kre
606 1.1 kre cmd='printf "%s\n" foo'
607 1.1 kre for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
608 1.1 kre do
609 1.1 kre atf_check -s exit:0 -o inline:'foo\n' -e empty ${TEST_SH} -c \
610 1.1 kre "${cmd}"
611 1.1 kre cmd="${cmd} |
612 1.1 kre
613 1.1 kre
614 1.1 kre
615 1.1 kre
616 1.1 kre cat"
617 1.1 kre done
618 1.1 kre
619 1.1 kre cmd='! printf "%s\n" foo'
620 1.1 kre for n in 1 2 3 4 5 6 7 8 9 10
621 1.1 kre do
622 1.1 kre atf_check -s exit:1 -o inline:'foo\n' -e empty ${TEST_SH} -c \
623 1.1 kre "${cmd}"
624 1.1 kre cmd="${cmd} | cat"
625 1.1 kre done
626 1.1 kre
627 1.1 kre cmd='exec 4>&2 3<&0; printf "%s\n" foo'
628 1.1 kre for n in 1 2 3
629 1.1 kre do
630 1.1 kre pfx=
631 1.1 kre for xtra in 'x=y' 'a=b' '6>&1' '5<&3'
632 1.1 kre do
633 1.1 kre atf_check -s exit:0 -o inline:'foo\n' -e empty ${TEST_SH} -c \
634 1.1 kre "${cmd} | ${xtra} cat"
635 1.1 kre
636 1.1 kre atf_check -s exit:0 -o inline:'foo\n' -e empty ${TEST_SH} -c \
637 1.1 kre "${cmd} | ${pfx} cat"
638 1.1 kre
639 1.1 kre pfx="${pfx} ${xtra}"
640 1.1 kre done
641 1.1 kre cmd="${cmd} | ${pfx} cat"
642 1.1 kre done
643 1.1 kre
644 1.1 kre # pipelines are not required to contain commands ...
645 1.1 kre # they don't do anything useful (at all) but the syntax is legal
646 1.1 kre base='4>&2'; cmd="${base}"
647 1.1 kre for pipe in 'a=b' '3<&0' '>>/dev/null' 'a= b= c=' '${x}' 'cat'
648 1.1 kre do
649 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
650 1.1 kre "${base} | ${pipe}"
651 1.1 kre
652 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
653 1.1 kre "${cmd} | ${pipe}"
654 1.1 kre
655 1.1 kre cmd="${cmd} | ${pipe}"
656 1.1 kre done
657 1.1 kre
658 1.1 kre # but the command cannot be empty, or a reserved word used improperly
659 1.1 kre base='printf "%s\n" foo'; cmd="${base}"
660 1.1 kre for pipe in '' do done then else fi esac
661 1.1 kre do
662 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
663 1.1 kre "${base} | ${pipe}"
664 1.1 kre
665 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
666 1.1 kre "${pipe} | ${base}"
667 1.1 kre
668 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
669 1.1 kre "${cmd} | ${pipe}"
670 1.1 kre
671 1.1 kre cmd="${cmd} | ${pipe}"
672 1.1 kre done
673 1.1 kre }
674 1.1 kre
675 1.1 kre atf_test_case j_and_or_lists
676 1.1 kre j_and_or_lists_head() {
677 1.1 kre atf_set "descr" "Check && and || command lists"
678 1.1 kre }
679 1.1 kre j_and_or_lists_body() {
680 1.1 kre and=true
681 1.1 kre or=false
682 1.1 kre and_or=false
683 1.1 kre for i in 1 2 3 4 5 6 7 8 9 10
684 1.1 kre do
685 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
686 1.1 kre "${and}"
687 1.1 kre
688 1.1 kre atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
689 1.1 kre "${or}"
690 1.1 kre
691 1.1 kre atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
692 1.1 kre "${and_or}"
693 1.1 kre
694 1.1 kre and="${and} && true"
695 1.1 kre or="${or} || false"
696 1.1 kre and_or="${and_or} || true && false"
697 1.1 kre done
698 1.1 kre
699 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
700 1.1 kre 'true &&'
701 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
702 1.1 kre '&& true'
703 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
704 1.1 kre '|| true'
705 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
706 1.1 kre 'true ||'
707 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
708 1.1 kre 'true || && false'
709 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
710 1.1 kre 'false || && true'
711 1.1 kre
712 1.1 kre cmd='printf "%s" foo | cat | cat>/dev/null'
713 1.1 kre line="${cmd}"
714 1.1 kre for i in 1 2 3 4
715 1.1 kre do
716 1.1 kre line="${line} && ! ${cmd} || ${cmd}"
717 1.1 kre
718 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
719 1.1 kre "${line}"
720 1.1 kre done
721 1.1 kre
722 1.1 kre }
723 1.1 kre
724 1.1 kre atf_test_case k_lists
725 1.1 kre k_lists_head() {
726 1.1 kre atf_set "descr" "Check ; command lists"
727 1.1 kre }
728 1.1 kre k_lists_body() {
729 1.1 kre line=
730 1.1 kre for N in 1 2 3 4
731 1.1 kre do
732 1.1 kre for cmd in \
733 1.1 kre true false : 'cat</dev/null>/dev/null' x=3 'exec 4>&-'
734 1.1 kre do
735 1.1 kre line="${line}${line:+;}${cmd}"
736 1.1 kre atf_check -s exit:0 -o 'inline:hello\nworld\n' \
737 1.1 kre -e empty ${TEST_SH} -c \
738 1.1 kre "echo hello; ${line}; echo world"
739 1.1 kre atf_check -s exit:0 -o 'inline:hello\nworld\n' \
740 1.1 kre -e empty ${TEST_SH} -c \
741 1.1 kre "echo hello; ${line}; echo world;"
742 1.1 kre done
743 1.1 kre done
744 1.1 kre
745 1.1 kre for cmd in ';' ';;' 'false ;; true' 'false; ;true' '; true'
746 1.1 kre do
747 1.1 kre atf_check -s not-exit:0 -o ignore -e not-empty \
748 1.1 kre ${TEST_SH} -c "${cmd}"
749 1.1 kre done
750 1.1 kre }
751 1.1 kre
752 1.1 kre atf_test_case l_async_lists
753 1.1 kre l_async_lists_head() {
754 1.1 kre atf_set "descr" "Check & command lists"
755 1.1 kre }
756 1.1 kre l_async_lists_body() {
757 1.1 kre line=
758 1.1 kre for N in 1 2 3 4
759 1.1 kre do
760 1.1 kre for cmd in \
761 1.1 kre true false : 'cat</dev/null>/dev/null' x=3 'exec 4>&-'
762 1.1 kre do
763 1.1 kre line="${line:+${line}&}${cmd}"
764 1.1 kre atf_check -s exit:0 -o 'inline:hello\nworld\n' \
765 1.1 kre -e empty ${TEST_SH} -c \
766 1.1 kre "echo hello; ${line}& echo world"
767 1.1 kre atf_check -s exit:0 -o 'inline:hello\nworld\n' \
768 1.1 kre -e empty ${TEST_SH} -c \
769 1.1 kre "echo hello; ${line}& echo world"
770 1.1 kre done
771 1.1 kre done
772 1.1 kre
773 1.1 kre for cmd in '&' ';&' '&;' '& true' 'false& &true'
774 1.1 kre do
775 1.1 kre atf_check -s not-exit:0 -o ignore -e not-empty \
776 1.1 kre ${TEST_SH} -c "${cmd}"
777 1.1 kre done
778 1.1 kre }
779 1.1 kre
780 1.1 kre atf_test_case m_compound_lists
781 1.1 kre m_compound_lists_head() {
782 1.1 kre atf_set "descr" "Check subshells () and { ;} command grouping"
783 1.1 kre }
784 1.1 kre m_compound_lists_body() {
785 1.1 kre # Note: (( is an unspecified (reserved) operator, don't use it...
786 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
787 1.1 kre '( true )'
788 1.1 kre atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
789 1.1 kre '( false )'
790 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
791 1.1 kre '( (:) )'
792 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
793 1.1 kre '( ( true ))'
794 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
795 1.1 kre '( ( ( ( ( true )))))'
796 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
797 1.1 kre '( ( ( ( (true);:));true))'
798 1.1 kre
799 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
800 1.1 kre '()'
801 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
802 1.1 kre '( )'
803 1.1 kre
804 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
805 1.1 kre '{ true; }'
806 1.1 kre atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
807 1.1 kre '{ false; }'
808 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
809 1.1 kre '{ { :; };}'
810 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
811 1.1 kre '{ { { { { :;};};};};}'
812 1.1 kre
813 1.1 kre atf_check -s exit:0 -o 'inline:}\n' -e empty ${TEST_SH} -c \
814 1.1 kre '{ echo } ; }'
815 1.1 kre atf_check -s exit:0 -o 'inline:{\n' -e empty ${TEST_SH} -c \
816 1.1 kre '{ echo { ; }'
817 1.1 kre }
818 1.1 kre
819 1.1 kre atf_test_case q_for_loop
820 1.1 kre q_for_loop_head() {
821 1.1 kre atf_set "descr" "Check for loop parsing"
822 1.1 kre }
823 1.1 kre q_for_loop_body() {
824 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
825 1.1 kre 'for x; do : ; done'
826 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
827 1.1 kre 'for x in ; do : ; done'
828 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
829 1.1 kre 'for x in a b c ; do : ; done'
830 1.1 kre
831 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
832 1.1 kre 'for x in in;do : ; done'
833 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
834 1.1 kre 'for x in for;do : ; done'
835 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
836 1.1 kre 'for x in do;do : ; done'
837 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
838 1.1 kre 'for for in in;do :;done'
839 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
840 1.1 kre 'for for in for;do :; done'
841 1.2 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
842 1.2 kre 'for for in do;do : ;done'
843 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
844 1.1 kre 'for in in in;do : ; done'
845 1.1 kre atf_check -s exit:0 -o 'inline:do\nin\ndo\n' -e empty ${TEST_SH} -c \
846 1.1 kre 'for in in in do in;do case $in in in)echo do;;do)echo in;;esac; done'
847 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
848 1.1 kre 'for in in for;do : ; done'
849 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
850 1.1 kre 'for in in do;do : ; done'
851 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
852 1.1 kre 'for do in in;do : ; done'
853 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
854 1.1 kre 'for do in for;do : ; done'
855 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
856 1.1 kre 'for do in do;do : ; done'
857 1.1 kre atf_check -s exit:0 -o 'inline:dodo\n' -e empty ${TEST_SH} -c \
858 1.1 kre 'for do in do;do echo ${do}do ; done'
859 1.1 kre }
860 1.1 kre
861 1.1 kre atf_test_case r_case
862 1.1 kre r_case_head() {
863 1.1 kre atf_set "descr" "Check case statement parsing"
864 1.1 kre }
865 1.1 kre r_case_body() {
866 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
867 1.1 kre 'case x in esac'
868 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
869 1.1 kre 'case x in x) esac'
870 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
871 1.1 kre 'case x in (x) esac'
872 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
873 1.1 kre 'case x in x) ;; esac'
874 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
875 1.1 kre 'case x in (x) ;; esac'
876 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
877 1.1 kre 'case x in x|y) ;; esac'
878 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
879 1.1 kre 'case x in (x|y) ;; esac'
880 1.1 kre
881 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
882 1.1 kre 'case x in x|esac) ;; esac'
883 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
884 1.1 kre 'case x in x|esac|y) ;; esac'
885 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
886 1.1 kre 'case x in (x|esac) ;; esac'
887 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
888 1.1 kre 'case x in (x|esac|y) ;; esac'
889 1.1 kre
890 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
891 1.1 kre 'case x in in) esac'
892 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
893 1.1 kre 'case x in in) ;; esac'
894 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
895 1.1 kre 'case x in x|in) ;; esac'
896 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
897 1.1 kre 'case x in x|in|y) ;; esac'
898 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
899 1.1 kre 'case x in (x|in) ;; esac'
900 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
901 1.1 kre 'case x in (in|x) ;; esac'
902 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
903 1.1 kre 'case x in (x|in|y) ;; esac'
904 1.1 kre
905 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
906 1.1 kre 'case case in case) esac'
907 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
908 1.1 kre 'case in in in) esac'
909 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
910 1.1 kre 'case esac in (in) esac'
911 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
912 1.1 kre 'case in in esac|cat'
913 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
914 1.1 kre 'case esac in esac|cat'
915 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
916 1.1 kre 'case in in esac|case x in u) echo foo;; esac'
917 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
918 1.1 kre 'case esac in esac|case x in u) echo foo;; esac'
919 1.1 kre atf_check -s exit:0 -o 'inline:foo\n' -e empty ${TEST_SH} -c \
920 1.1 kre 'case in in esac|case x in x) echo foo;; esac'
921 1.1 kre
922 1.1 kre atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
923 1.1 kre 'case in in (esac|cat'
924 1.1 kre
925 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
926 1.1 kre 'case x in x );;esac'
927 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
928 1.1 kre 'case x in ( x );;esac'
929 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
930 1.1 kre 'case x in x | y );;esac'
931 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
932 1.1 kre 'case x in ( x | y );;esac'
933 1.1 kre
934 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
935 1.1 kre 'case x
936 1.1 kre in
937 1.1 kre ( x | y )
938 1.1 kre
939 1.1 kre ;;
940 1.1 kre
941 1.1 kre
942 1.1 kre esac
943 1.1 kre '
944 1.1 kre }
945 1.1 kre
946 1.1 kre atf_test_case s_if
947 1.1 kre s_if_head() {
948 1.1 kre atf_set "descr" "Check if statement parsing"
949 1.1 kre }
950 1.1 kre s_if_body() {
951 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
952 1.1 kre 'if :; then :; fi'
953 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
954 1.1 kre 'if :; then :; else :; fi'
955 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
956 1.1 kre 'if :; then :; elif :; then :; else :; fi'
957 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
958 1.1 kre 'if :; then :; elif :; then :; elif :; then :; else :; fi'
959 1.1 kre
960 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
961 1.1 kre 'if :; then : else :; fi'
962 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
963 1.1 kre 'if : then :; then :; fi'
964 1.1 kre
965 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
966 1.1 kre 'if if :;then :;fi then :;fi'
967 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
968 1.1 kre 'if if :;then if :;then :;fi fi;then :;fi'
969 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
970 1.1 kre 'if if :;then :;fi;then :;else if :;then :;fi fi'
971 1.1 kre
972 1.1 kre for a in true false; do
973 1.1 kre for b in true false; do
974 1.1 kre for c in true false; do
975 1.1 kre
976 1.1 kre $a && out=a || {
977 1.1 kre $b && out=b || {
978 1.1 kre $c && out=c || {
979 1.1 kre out=d; };};}
980 1.1 kre
981 1.1 kre atf_check -s exit:0 -e empty \
982 1.1 kre -o "inline:${out}"'\n' \
983 1.1 kre ${TEST_SH} -c \
984 1.1 kre "if $a; then echo a
985 1.1 kre elif $b; then echo b
986 1.1 kre elif $c; then echo c
987 1.1 kre else echo d
988 1.1 kre fi"
989 1.1 kre done
990 1.1 kre done
991 1.1 kre done
992 1.1 kre }
993 1.1 kre
994 1.1 kre atf_test_case t_loops
995 1.1 kre t_loops_head() {
996 1.1 kre atf_set "descr" "Check while/until loop parsing"
997 1.1 kre }
998 1.1 kre t_loops_body() {
999 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1000 1.1 kre 'while false; do :; done'
1001 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1002 1.1 kre 'while false; do \done; done'
1003 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1004 1.1 kre 'until :; do :; done'
1005 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1006 1.1 kre 'until :; do \done; done'
1007 1.1 kre
1008 1.1 kre atf_check -s exit:0 -o 'inline:x\n1\n' -e empty ${TEST_SH} -c \
1009 1.1 kre ':; while (exit) do echo x; false; done; echo $?'
1010 1.1 kre atf_check -s exit:0 -o 'inline:x\n0\n' -e empty ${TEST_SH} -c \
1011 1.1 kre 'false; until (exit) do echo x; done; echo $?'
1012 1.1 kre }
1013 1.1 kre
1014 1.1 kre atf_test_case u_case_cont
1015 1.1 kre u_case_cont_head() {
1016 1.1 kre atf_set "descr" "Check case stmt parsing using ;& [optional]"
1017 1.1 kre }
1018 1.1 kre u_case_cont_body() {
1019 1.1 kre
1020 1.1 kre ${TEST_SH} -c 'case x in (x) false ;& (y) : ;; esac' 2>/dev/null ||
1021 1.1 kre atf_skip ";& case list terminator unsupported in ${TEST_SH}"
1022 1.1 kre
1023 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1024 1.1 kre 'case x in x) ;& esac'
1025 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1026 1.1 kre 'case x in (x) ;& esac'
1027 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1028 1.1 kre 'case x in x|y) ;& esac'
1029 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1030 1.1 kre 'case x in (x|y) ;& esac'
1031 1.1 kre
1032 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1033 1.1 kre 'case x in x );&esac'
1034 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1035 1.1 kre 'case x in ( x );&esac'
1036 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1037 1.1 kre 'case x in x | y );&esac'
1038 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1039 1.1 kre 'case x in ( x | y );&esac'
1040 1.1 kre
1041 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1042 1.1 kre 'case x in x) ;& (y) esac'
1043 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1044 1.1 kre 'case x in (x) ;& esac'
1045 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1046 1.1 kre 'case x in x|y) ;& esac'
1047 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1048 1.1 kre 'case x in (x|y) ;& esac'
1049 1.1 kre }
1050 1.1 kre
1051 1.1 kre atf_test_case x_functions
1052 1.1 kre x_functions_head() {
1053 1.1 kre atf_set "descr" "Check function definition parsing"
1054 1.1 kre }
1055 1.1 kre x_functions_body() {
1056 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1057 1.1 kre 'func() { :; }'
1058 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1059 1.1 kre 'func() { :; }; func'
1060 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1061 1.1 kre 'func()(:)'
1062 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1063 1.1 kre 'func()if :; then false; else true; fi'
1064 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1065 1.1 kre 'func()while false; do :;done'
1066 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1067 1.1 kre 'func () for a in b c; do :; done'
1068 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1069 1.1 kre 'func() case x in (y) esac'
1070 1.1 kre
1071 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1072 1.1 kre 'f1() { f2() { :; }; }; f1; f2'
1073 1.1 kre
1074 1.1 kre # f2 should be not found, but f1 clears $?
1075 1.1 kre atf_check -s exit:0 -o empty -e not-empty ${TEST_SH} -c \
1076 1.1 kre 'f1() { f2() { :; }; }; f2; f1'
1077 1.1 kre
1078 1.6 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1079 1.6 kre 'f1() { eval "$1() { :; }"; }; f1 f2; f2'
1080 1.6 kre }
1081 1.6 kre
1082 1.6 kre atf_test_case z_PR_48498
1083 1.6 kre z_PR_48498_head() {
1084 1.6 kre atf_set "descr" "Check for detecting the syntax error from PR bin/48498"
1085 1.6 kre }
1086 1.6 kre z_PR_48498_body() {
1087 1.6 kre
1088 1.6 kre # reserved words/operators that end things,
1089 1.6 kre # were completely ignored after a ';' or '&'
1090 1.6 kre # many of these tests lifted directly from the PR
1091 1.6 kre
1092 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1093 1.6 kre 'true; fi'
1094 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1095 1.6 kre 'false; fi'
1096 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1097 1.6 kre 'false; then echo wut'
1098 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1099 1.6 kre 'true; then echo wut'
1100 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1101 1.6 kre 'true; do echo wut'
1102 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1103 1.6 kre 'true; then'
1104 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1105 1.6 kre 'true; else'
1106 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1107 1.6 kre 'true; do'
1108 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1109 1.6 kre 'true; done'
1110 1.6 kre # {
1111 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1112 1.6 kre ': ; }'
1113 1.6 kre # (
1114 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1115 1.6 kre ':;)'
1116 1.6 kre
1117 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1118 1.6 kre 'true& fi'
1119 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1120 1.6 kre 'false& fi'
1121 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1122 1.6 kre 'false& then echo wut'
1123 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1124 1.6 kre 'true& then echo wut'
1125 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1126 1.6 kre 'true& do echo wut'
1127 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1128 1.6 kre 'true& then'
1129 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1130 1.6 kre 'true& else'
1131 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1132 1.6 kre 'true& do'
1133 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1134 1.6 kre 'true&done'
1135 1.6 kre # {
1136 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1137 1.6 kre ':&}'
1138 1.6 kre # (
1139 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1140 1.6 kre ':&)'
1141 1.6 kre }
1142 1.6 kre
1143 1.6 kre atf_test_case z_PR_52426
1144 1.6 kre z_PR_52426_head() {
1145 1.6 kre atf_set "descr" "Check for detecting the syntax error from PR bin/52426"
1146 1.6 kre }
1147 1.6 kre z_PR_52426_body() {
1148 1.6 kre # Absoluely anything was permitted as a pattern of a case
1149 1.6 kre # statement, any token (except 'esac') would serve
1150 1.6 kre # What follows are a few "pretty" examples that were accepted.
1151 1.6 kre # The first is the example from the PR
1152 1.6 kre
1153 1.6 kre # Note we use only ;; type case lists, ;& should do the same, but
1154 1.6 kre # only for shells that support it, we do not want the shell to
1155 1.6 kre # object to any of these just because it does not support ;&
1156 1.6 kre
1157 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1158 1.6 kre 'case x in <|() ;; esac'
1159 1.6 kre
1160 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1161 1.6 kre 'case x in ((|)) ;; esac'
1162 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1163 1.6 kre 'case x in _|() ;; esac'
1164 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1165 1.6 kre 'case x in ()|() ;; esac'
1166 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1167 1.6 kre 'case x in -|;) ;; esac'
1168 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1169 1.6 kre 'case x in (;|-) ;; esac'
1170 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1171 1.6 kre 'case x in ;;|;) ;; esac'
1172 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1173 1.6 kre 'case x in (|| | ||) ;; esac'
1174 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1175 1.6 kre 'case x in (<<|>>) ;; esac'
1176 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1177 1.6 kre 'case x in (&&|&) ;; (|||>&) ;; &) esac'
1178 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1179 1.6 kre 'case x in (>||<) ;; esac'
1180 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1181 1.6 kre 'case x in( || | || | || | || | || );; esac'
1182 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1183 1.6 kre 'case x in (||| ||| ||| ||| ||) ;; esac'
1184 1.6 kre atf_check -s not-exit:0 -o ignore -e not-empty ${TEST_SH} -c \
1185 1.6 kre 'case x in <> |
1186 1.6 kre ) ;; esac'
1187 1.6 kre
1188 1.6 kre # now check some similar looking cases that are supposed to work
1189 1.6 kre # That is, make sure the fix for the PR does not break valid cases.
1190 1.6 kre
1191 1.6 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1192 1.6 kre 'case fi in ({|}) ;; (!) ;; esac'
1193 1.6 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1194 1.6 kre 'case esac in ([|]);; (][);; !!!|!!!|!!!|!!!);; esac'
1195 1.6 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1196 1.6 kre 'case then in ({[]]}) ;; (^^);; (^|^);; ([!]);; (-);; esac'
1197 1.6 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1198 1.6 kre 'case while in while );;(if|then|elif|fi);;(do|done);; esac'
1199 1.6 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1200 1.6 kre 'case until in($);;($$);;($4.50);;(1/2);;0.3333);;esac'
1201 1.6 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1202 1.6 kre 'case return in !);; !$);; $!);; !#);; (@);; esac'
1203 1.1 kre atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
1204 1.1 kre 'case break in (/);; (\/);; (/\|/\));; (\\//);; esac'
1205 1.1 kre }
1206 1.1 kre
1207 1.7 kre atf_init_test_cases() {
1208 1.7 kre atf_add_test_case a_basic_tokenisation
1209 1.7 kre atf_add_test_case b_comments
1210 1.7 kre atf_add_test_case c_line_wrapping
1211 1.1 kre atf_add_test_case d_cstrings
1212 1.1 kre atf_add_test_case f_redirects
1213 1.1 kre atf_add_test_case g_variable_syntax
1214 1.1 kre atf_add_test_case h_var_assign
1215 1.1 kre atf_add_test_case i_pipelines
1216 1.1 kre atf_add_test_case j_and_or_lists
1217 1.1 kre atf_add_test_case k_lists
1218 1.1 kre atf_add_test_case l_async_lists
1219 1.1 kre atf_add_test_case m_compound_lists
1220 1.1 kre atf_add_test_case q_for_loop
1221 1.1 kre atf_add_test_case r_case
1222 1.6 kre atf_add_test_case s_if
1223 1.6 kre atf_add_test_case t_loops
1224 1.6 kre atf_add_test_case u_case_cont
1225 1.1 kre atf_add_test_case x_functions
1226
1227 atf_add_test_case z_PR_48498
1228 atf_add_test_case z_PR_52426
1229 }
1230