xref: /openbsd/regress/bin/ksh/unclass2.t (revision 4cfece93)
1name: xxx-subsitution-eval-order
2description:
3	Check order of evaluation of expressions
4stdin:
5	i=1 x= y=
6	set -A A abc def GHI j G k
7	echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
8	echo $x $y
9expected-stdout:
10	HI
11	2 4
12---
13
14name: xxx-set-option-1
15description:
16	Check option parsing in set
17stdin:
18	set -vsA foo -- A 1 3 2
19	echo ${foo[*]}
20expected-stderr:
21	echo ${foo[*]}
22expected-stdout:
23	1 2 3 A
24---
25
26name: xxx-exec-1
27description:
28	Check that exec exits for built-ins
29arguments: !-i!
30stdin:
31	exec print hi
32	echo still herre
33expected-stdout:
34	hi
35expected-stderr-pattern: /.*/
36---
37
38name: xxx-while-1
39description:
40	Check the return value of while loops
41	XXX need to do same for for/select/until loops
42stdin:
43	i=x
44	while [ $i != xxx ] ; do
45	    i=x$i
46	    if [ $i = xxx ] ; then
47		false
48		continue
49	    fi
50	done
51	echo loop1=$?
52
53	i=x
54	while [ $i != xxx ] ; do
55	    i=x$i
56	    if [ $i = xxx ] ; then
57		false
58		break
59	    fi
60	done
61	echo loop2=$?
62
63	i=x
64	while [ $i != xxx ] ; do
65	    i=x$i
66	    false
67	done
68	echo loop3=$?
69expected-stdout:
70	loop1=0
71	loop2=0
72	loop3=1
73---
74
75name: xxx-status-1
76description:
77	Check that blank lines don't clear $?
78arguments: !-i!
79stdin:
80	(exit 1)
81	echo $?
82	(exit 1)
83
84	echo $?
85	true
86expected-stdout:
87	1
88	1
89expected-stderr-pattern: /.*/
90---
91
92name: xxx-status-2
93description:
94	Check that $? is preserved in subshells, includes, traps.
95stdin:
96	(exit 1)
97
98	echo blank: $?
99
100	(exit 2)
101	(echo subshell: $?)
102
103	echo 'echo include: $?' > foo
104	(exit 3)
105	. ./foo
106
107	trap 'echo trap: $?' ERR
108	(exit 4)
109	echo exit: $?
110expected-stdout:
111	blank: 1
112	subshell: 2
113	include: 3
114	trap: 4
115	exit: 4
116---
117
118name: xxx-clean-chars-1
119description:
120	Check MAGIC character is stuffed correctly
121stdin:
122	echo `echo [�`
123expected-stdout:
124	[�
125---
126
127name: xxx-param-subst-qmark-1
128description:
129	Check suppresion of error message with null string.  According to
130	POSIX, it shouldn't print the error as `word' isn't ommitted.
131stdin:
132	unset foo
133	x=
134	echo x${foo?$x}
135expected-exit: 1
136expected-fail: yes
137expected-stderr-pattern: !/not set/
138---
139
140name: xxx-param-_-1
141description:
142	Check c flag is set.
143arguments: !-c!echo "[$-]"!
144expected-stdout-pattern: /^\[.*c.*\]$/
145---
146
147name: env-prompt
148description:
149	Check that prompt not printed when processing ENV
150env-setup: !ENV=./foo!
151file-setup: file 644 "foo"
152	XXX=_
153	PS1=X
154	false && echo hmmm
155arguments: !-i!
156stdin:
157	echo hi${XXX}there
158expected-stdout:
159	hi_there
160expected-stderr-pattern:
161	/^XX$/m
162---
163
164name: single-quotes-in-braces
165description:
166	Check that single quotes inside unquoted {} are treated as quotes
167stdin:
168	foo=1
169	echo ${foo:+'blah  $foo'}
170expected-stdout:
171	blah  $foo
172---
173
174name: single-quotes-in-quoted-braces
175description:
176	Check that single quotes inside quoted {} are treated as
177	normal char
178stdin:
179	foo=1
180	echo "${foo:+'blah  $foo'}"
181expected-stdout:
182	'blah  1'
183---
184
185name: single-quotes-in-braces-nested
186description:
187	Check that single quotes inside unquoted {} are treated as quotes,
188	even if that's inside a double-quoted command expansion
189stdin:
190	foo=1
191	echo "$( echo ${foo:+'blah  $foo'})"
192expected-stdout:
193	blah  $foo
194---
195
196name: single-quotes-in-brace-pattern
197description:
198	Check that single quotes inside {} pattern are treated as quotes
199stdin:
200	foo=1234
201	echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
202expected-stdout:
203	1 1 1234 1234
204---
205
206name: single-quotes-in-heredoc-braces
207description:
208	Check that single quotes inside {} in heredoc are treated
209	as normal char
210stdin:
211	foo=1
212	cat <<EOM
213	${foo:+'blah  $foo'}
214	EOM
215expected-stdout:
216	'blah  1'
217---
218
219name: single-quotes-in-nested-braces
220description:
221	Check that single quotes inside nested unquoted {} are
222	treated as quotes
223stdin:
224	foo=1
225	echo ${foo:+${foo:+'blah  $foo'}}
226expected-stdout:
227	blah  $foo
228---
229
230name: single-quotes-in-nested-quoted-braces
231description:
232	Check that single quotes inside nested quoted {} are treated
233	as normal char
234stdin:
235	foo=1
236	echo "${foo:+${foo:+'blah  $foo'}}"
237expected-stdout:
238	'blah  1'
239---
240
241name: single-quotes-in-nested-braces-nested
242description:
243	Check that single quotes inside nested unquoted {} are treated
244	as quotes, even if that's inside a double-quoted command expansion
245stdin:
246	foo=1
247	echo "$( echo ${foo:+${foo:+'blah  $foo'}})"
248expected-stdout:
249	blah  $foo
250---
251
252name: single-quotes-in-nested-brace-pattern
253description:
254	Check that single quotes inside nested {} pattern are treated as quotes
255stdin:
256	foo=1234
257	echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
258expected-stdout:
259	1 1 1234 1234
260---
261
262name: single-quotes-in-heredoc-nested-braces
263description:
264	Check that single quotes inside nested {} in heredoc are treated
265	as normal char
266stdin:
267	foo=1
268	cat <<EOM
269	${foo:+${foo:+'blah  $foo'}}
270	EOM
271expected-stdout:
272	'blah  1'
273---
274