xref: /minix3/tests/bin/sh/t_set_e.sh (revision 11be35a165022172ed3cea20f2b5df0307540b0e)
1*11be35a1SLionel Sambuc# $NetBSD: t_set_e.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $
2*11be35a1SLionel Sambuc#
3*11be35a1SLionel Sambuc# Copyright (c) 2007 The NetBSD Foundation, Inc.
4*11be35a1SLionel Sambuc# All rights reserved.
5*11be35a1SLionel Sambuc#
6*11be35a1SLionel Sambuc# Redistribution and use in source and binary forms, with or without
7*11be35a1SLionel Sambuc# modification, are permitted provided that the following conditions
8*11be35a1SLionel Sambuc# are met:
9*11be35a1SLionel Sambuc# 1. Redistributions of source code must retain the above copyright
10*11be35a1SLionel Sambuc#    notice, this list of conditions and the following disclaimer.
11*11be35a1SLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright
12*11be35a1SLionel Sambuc#    notice, this list of conditions and the following disclaimer in the
13*11be35a1SLionel Sambuc#    documentation and/or other materials provided with the distribution.
14*11be35a1SLionel Sambuc#
15*11be35a1SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16*11be35a1SLionel Sambuc# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17*11be35a1SLionel Sambuc# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18*11be35a1SLionel Sambuc# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19*11be35a1SLionel Sambuc# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20*11be35a1SLionel Sambuc# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21*11be35a1SLionel Sambuc# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22*11be35a1SLionel Sambuc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23*11be35a1SLionel Sambuc# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24*11be35a1SLionel Sambuc# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25*11be35a1SLionel Sambuc# POSSIBILITY OF SUCH DAMAGE.
26*11be35a1SLionel Sambuc#
27*11be35a1SLionel Sambuc
28*11be35a1SLionel Sambuc# references:
29*11be35a1SLionel Sambuc#   http://www.opengroup.org/onlinepubs/009695399/utilities/set.html
30*11be35a1SLionel Sambuc#   http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
31*11be35a1SLionel Sambuc
32*11be35a1SLionel Sambuc# the implementation of "sh" to test
33*11be35a1SLionel Sambuc: ${TEST_SH:="sh"}
34*11be35a1SLionel Sambuc
35*11be35a1SLionel Sambucfailwith()
36*11be35a1SLionel Sambuc{
37*11be35a1SLionel Sambuc	case "$SH_FAILS" in
38*11be35a1SLionel Sambuc		"") SH_FAILS=`echo "$1"`;;
39*11be35a1SLionel Sambuc		*) SH_FAILS="$SH_FAILS"`echo; echo "$1"`;;
40*11be35a1SLionel Sambuc	esac
41*11be35a1SLionel Sambuc}
42*11be35a1SLionel Sambuc
43*11be35a1SLionel Sambuccheck1()
44*11be35a1SLionel Sambuc{
45*11be35a1SLionel Sambuc	#echo "$TEST_SH -c $1"
46*11be35a1SLionel Sambuc	result=`$TEST_SH -c "$1" 2>/dev/null | tr '\n' ' ' | sed 's/ *$//'`
47*11be35a1SLionel Sambuc	if [ "$result" != "$2" ]; then
48*11be35a1SLionel Sambuc		MSG=`printf "%-56s %-8s  %s" "$3" "$result" "$2"`
49*11be35a1SLionel Sambuc		failwith "$MSG"
50*11be35a1SLionel Sambuc		failcount=`expr $failcount + 1`
51*11be35a1SLionel Sambuc	fi
52*11be35a1SLionel Sambuc	count=`expr $count + 1`
53*11be35a1SLionel Sambuc}
54*11be35a1SLionel Sambuc
55*11be35a1SLionel Sambuc# direct check: try the given expression.
56*11be35a1SLionel Sambucdcheck()
57*11be35a1SLionel Sambuc{
58*11be35a1SLionel Sambuc	check1 "$1" "$2" "$1"
59*11be35a1SLionel Sambuc}
60*11be35a1SLionel Sambuc
61*11be35a1SLionel Sambuc# eval check: indirect through eval.
62*11be35a1SLionel Sambuc# as of this writing, this changes the behavior pretty drastically and
63*11be35a1SLionel Sambuc# is thus important to test. (PR bin/29861)
64*11be35a1SLionel Sambucecheck()
65*11be35a1SLionel Sambuc{
66*11be35a1SLionel Sambuc	check1 'eval '"'($1)'" "$2" "eval '($1)'"
67*11be35a1SLionel Sambuc}
68*11be35a1SLionel Sambuc
69*11be35a1SLionel Sambucatf_test_case all
70*11be35a1SLionel Sambucall_head() {
71*11be35a1SLionel Sambuc	atf_set "descr" "Tests that 'set -e' works correctly"
72*11be35a1SLionel Sambuc}
73*11be35a1SLionel Sambucall_body() {
74*11be35a1SLionel Sambuc	count=0
75*11be35a1SLionel Sambuc	failcount=0
76*11be35a1SLionel Sambuc
77*11be35a1SLionel Sambuc	# make sure exiting from a subshell behaves as expected
78*11be35a1SLionel Sambuc	dcheck '(set -e; exit 1; echo ERR$?); echo OK$?' 'OK1'
79*11be35a1SLionel Sambuc	echeck '(set -e; exit 1; echo ERR$?); echo OK$?' 'OK1'
80*11be35a1SLionel Sambuc
81*11be35a1SLionel Sambuc	# first, check basic functioning.
82*11be35a1SLionel Sambuc	# The ERR shouldn't print; the result of the () should be 1.
83*11be35a1SLionel Sambuc	# Henceforth we'll assume that we don't need to check $?.
84*11be35a1SLionel Sambuc	dcheck '(set -e; false; echo ERR$?); echo -n OK$?' 'OK1'
85*11be35a1SLionel Sambuc	echeck '(set -e; false; echo ERR$?); echo -n OK$?' 'OK1'
86*11be35a1SLionel Sambuc
87*11be35a1SLionel Sambuc	# these cases should be equivalent to the preceding.
88*11be35a1SLionel Sambuc	dcheck '(set -e; /nonexistent; echo ERR); echo OK' 'OK'
89*11be35a1SLionel Sambuc	echeck '(set -e; /nonexistent; echo ERR); echo OK' 'OK'
90*11be35a1SLionel Sambuc	dcheck '(set -e; nonexistent-program-on-path; echo ERR); echo OK' 'OK'
91*11be35a1SLionel Sambuc	echeck '(set -e; nonexistent-program-on-path; echo ERR); echo OK' 'OK'
92*11be35a1SLionel Sambuc	dcheck 'f() { false; }; (set -e; f; echo ERR); echo OK' 'OK'
93*11be35a1SLionel Sambuc	echeck 'f() { false; }; (set -e; f; echo ERR); echo OK' 'OK'
94*11be35a1SLionel Sambuc	dcheck 'f() { return 1; }; (set -e; f; echo ERR); echo OK' 'OK'
95*11be35a1SLionel Sambuc	echeck 'f() { return 1; }; (set -e; f; echo ERR); echo OK' 'OK'
96*11be35a1SLionel Sambuc
97*11be35a1SLionel Sambuc	# but! with set -e, the false should cause an *immediate* exit.
98*11be35a1SLionel Sambuc	# The return form should not, as such, but there's no way to
99*11be35a1SLionel Sambuc	# distinguish it.
100*11be35a1SLionel Sambuc	dcheck 'f() { false; echo ERR; }; (set -e; f); echo OK' 'OK'
101*11be35a1SLionel Sambuc	echeck 'f() { false; echo ERR; }; (set -e; f); echo OK' 'OK'
102*11be35a1SLionel Sambuc
103*11be35a1SLionel Sambuc	# set is not scoped, so these should not exit at all.
104*11be35a1SLionel Sambuc	dcheck 'f() { set +e; false; echo OK; }; (set -e; f); echo OK' 'OK OK'
105*11be35a1SLionel Sambuc	echeck 'f() { set +e; false; echo OK; }; (set -e; f); echo OK' 'OK OK'
106*11be35a1SLionel Sambuc
107*11be35a1SLionel Sambuc	# according to the standard, only failing *simple* commands
108*11be35a1SLionel Sambuc	# cause an exit under -e. () is not a simple command.
109*11be35a1SLionel Sambuc	#   Correct (per POSIX):
110*11be35a1SLionel Sambuc	#dcheck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK OK'
111*11be35a1SLionel Sambuc	#echeck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK OK'
112*11be35a1SLionel Sambuc	#   Wrong current behavior:
113*11be35a1SLionel Sambuc	dcheck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK'
114*11be35a1SLionel Sambuc	echeck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK'
115*11be35a1SLionel Sambuc
116*11be35a1SLionel Sambuc	# make sure an inner nested shell does exit though.
117*11be35a1SLionel Sambuc	dcheck '(set -e; (false; echo ERR)); echo OK' 'OK'
118*11be35a1SLionel Sambuc
119*11be35a1SLionel Sambuc	# The left hand side of an || or && is explicitly tested and
120*11be35a1SLionel Sambuc	# thus should not cause an exit. Furthermore, because a || or
121*11be35a1SLionel Sambuc	# && expression is not a simple command, there should be no
122*11be35a1SLionel Sambuc	# exit even if the overall result is false.
123*11be35a1SLionel Sambuc	dcheck '(set -e; false || true; echo OK); echo OK' 'OK OK'
124*11be35a1SLionel Sambuc	echeck '(set -e; false || true; echo OK); echo OK' 'OK OK'
125*11be35a1SLionel Sambuc	dcheck '(set -e; false && true; echo OK); echo OK' 'OK OK'
126*11be35a1SLionel Sambuc	echeck '(set -e; false && true; echo OK); echo OK' 'OK OK'
127*11be35a1SLionel Sambuc
128*11be35a1SLionel Sambuc	# However, the right hand side is not tested, so a failure
129*11be35a1SLionel Sambuc	# there *should* cause an exit, regardless of whether it
130*11be35a1SLionel Sambuc	# appears inside a non-simple command.
131*11be35a1SLionel Sambuc	#
132*11be35a1SLionel Sambuc	# Note that in at least one place the standard does not
133*11be35a1SLionel Sambuc	# distinguish between the left and right hand sides of
134*11be35a1SLionel Sambuc	# logical operators. It is possible that for strict
135*11be35a1SLionel Sambuc	# compliance these need to not exit; however, if so that
136*11be35a1SLionel Sambuc	# should probably be limited to when some strict-posix setting
137*11be35a1SLionel Sambuc	# is in effect and tested accordingly.
138*11be35a1SLionel Sambuc	#
139*11be35a1SLionel Sambuc	dcheck '(set -e; false || false; echo ERR); echo OK' 'OK'
140*11be35a1SLionel Sambuc	dcheck '(set -e; true && false; echo ERR); echo OK' 'OK'
141*11be35a1SLionel Sambuc	echeck '(set -e; false || false; echo ERR); echo OK' 'OK'
142*11be35a1SLionel Sambuc	echeck '(set -e; true && false; echo ERR); echo OK' 'OK'
143*11be35a1SLionel Sambuc
144*11be35a1SLionel Sambuc	# correct:
145*11be35a1SLionel Sambuc	#dcheck '(set -e; false && false; echo ERR); echo OK' 'OK'
146*11be35a1SLionel Sambuc	#echeck '(set -e; false && false; echo ERR); echo OK' 'OK'
147*11be35a1SLionel Sambuc
148*11be35a1SLionel Sambuc	# wrong current behavior:
149*11be35a1SLionel Sambuc	dcheck '(set -e; false && false; echo ERR); echo OK' 'ERR OK'
150*11be35a1SLionel Sambuc	echeck '(set -e; false && false; echo ERR); echo OK' 'ERR OK'
151*11be35a1SLionel Sambuc
152*11be35a1SLionel Sambuc	# A failure that is not reached because of short-circuit
153*11be35a1SLionel Sambuc	# evaluation should not cause an exit, however.
154*11be35a1SLionel Sambuc	dcheck '(set -e; true || false; echo OK); echo OK' 'OK OK'
155*11be35a1SLionel Sambuc	echeck '(set -e; true || false; echo OK); echo OK' 'OK OK'
156*11be35a1SLionel Sambuc
157*11be35a1SLionel Sambuc	# For completeness, test the other two combinations.
158*11be35a1SLionel Sambuc	dcheck '(set -e; true || true; echo OK); echo OK' 'OK OK'
159*11be35a1SLionel Sambuc	dcheck '(set -e; true && true; echo OK); echo OK' 'OK OK'
160*11be35a1SLionel Sambuc	echeck '(set -e; true || true; echo OK); echo OK' 'OK OK'
161*11be35a1SLionel Sambuc	echeck '(set -e; true && true; echo OK); echo OK' 'OK OK'
162*11be35a1SLionel Sambuc
163*11be35a1SLionel Sambuc	# likewise, none of these should exit.
164*11be35a1SLionel Sambuc	dcheck '(set -e; while false; do :; done; echo OK); echo OK' 'OK OK'
165*11be35a1SLionel Sambuc	dcheck '(set -e; if false; then :; fi; echo OK); echo OK' 'OK OK'
166*11be35a1SLionel Sambuc	# problematic :-)
167*11be35a1SLionel Sambuc	#dcheck '(set -e; until false; do :; done; echo OK); echo OK' 'OK OK'
168*11be35a1SLionel Sambuc	dcheck '(set -e; until [ "$t" = 1 ]; do t=1; done; echo OK); echo OK' \
169*11be35a1SLionel Sambuc	  'OK OK'
170*11be35a1SLionel Sambuc	echeck '(set -e; while false; do :; done; echo OK); echo OK' 'OK OK'
171*11be35a1SLionel Sambuc	echeck '(set -e; if false; then :; fi; echo OK); echo OK' 'OK OK'
172*11be35a1SLionel Sambuc	echeck '(set -e; until [ "$t" = 1 ]; do t=1; done; echo OK); echo OK' \
173*11be35a1SLionel Sambuc	  'OK OK'
174*11be35a1SLionel Sambuc
175*11be35a1SLionel Sambuc	# the bang operator tests its argument and thus the argument
176*11be35a1SLionel Sambuc	# should not cause an exit. it is also not a simple command (I
177*11be35a1SLionel Sambuc	# believe) so it also shouldn't exit even if it yields a false
178*11be35a1SLionel Sambuc	# result.
179*11be35a1SLionel Sambuc	dcheck '(set -e; ! false; echo OK); echo OK' 'OK OK'
180*11be35a1SLionel Sambuc	dcheck '(set -e; ! true; echo OK); echo OK' 'OK OK'
181*11be35a1SLionel Sambuc	echeck '(set -e; ! false; echo OK); echo OK' 'OK OK'
182*11be35a1SLionel Sambuc	echeck '(set -e; ! true; echo OK); echo OK' 'OK OK'
183*11be35a1SLionel Sambuc
184*11be35a1SLionel Sambuc	# combined case with () and &&; the inner expression is false
185*11be35a1SLionel Sambuc	# but does not itself exit, and the () should not cause an
186*11be35a1SLionel Sambuc	# exit even when failing.
187*11be35a1SLionel Sambuc	# correct:
188*11be35a1SLionel Sambuc	#dcheck '(set -e; (false && true); echo OK); echo OK' 'OK OK'
189*11be35a1SLionel Sambuc	#echeck '(set -e; (false && true); echo OK); echo OK' 'OK OK'
190*11be35a1SLionel Sambuc	# wrong current behavior:
191*11be35a1SLionel Sambuc	dcheck '(set -e; (false && true); echo OK); echo OK' 'OK'
192*11be35a1SLionel Sambuc	echeck '(set -e; (false && true); echo OK); echo OK' 'OK'
193*11be35a1SLionel Sambuc
194*11be35a1SLionel Sambuc	# pipelines. only the right-hand end is significant.
195*11be35a1SLionel Sambuc	dcheck '(set -e; false | true; echo OK); echo OK' 'OK OK'
196*11be35a1SLionel Sambuc	echeck '(set -e; false | true; echo OK); echo OK' 'OK OK'
197*11be35a1SLionel Sambuc	dcheck '(set -e; true | false; echo ERR); echo OK' 'OK'
198*11be35a1SLionel Sambuc	echeck '(set -e; true | false; echo ERR); echo OK' 'OK'
199*11be35a1SLionel Sambuc
200*11be35a1SLionel Sambuc	dcheck '(set -e; while true | false; do :; done; echo OK); echo OK' \
201*11be35a1SLionel Sambuc	    'OK OK'
202*11be35a1SLionel Sambuc	dcheck '(set -e; if true | false; then :; fi; echo OK); echo OK' \
203*11be35a1SLionel Sambuc	    'OK OK'
204*11be35a1SLionel Sambuc
205*11be35a1SLionel Sambuc
206*11be35a1SLionel Sambuc	# According to dsl@ in PR bin/32282, () is not defined as a
207*11be35a1SLionel Sambuc	# subshell, only as a grouping operator [and a scope, I guess]
208*11be35a1SLionel Sambuc	# so the nested false ought to cause the whole shell to exit,
209*11be35a1SLionel Sambuc	# not just the subshell. dholland@ would like to see C&V,
210*11be35a1SLionel Sambuc	# because that seems like a bad idea. (Among other things, it
211*11be35a1SLionel Sambuc	# would break all the above test logic, which relies on being
212*11be35a1SLionel Sambuc	# able to isolate set -e behavior inside ().) However, I'm
213*11be35a1SLionel Sambuc	# going to put these tests here to make sure the issue gets
214*11be35a1SLionel Sambuc	# dealt with sometime.
215*11be35a1SLionel Sambuc	#
216*11be35a1SLionel Sambuc	# XXX: the second set has been disabled in the name of making
217*11be35a1SLionel Sambuc	# all tests "pass".
218*11be35a1SLionel Sambuc
219*11be35a1SLionel Sambuc	# 1. error if the whole shell exits (current behavior)
220*11be35a1SLionel Sambuc	dcheck 'echo OK; (set -e; false); echo OK' 'OK OK'
221*11be35a1SLionel Sambuc	echeck 'echo OK; (set -e; false); echo OK' 'OK OK'
222*11be35a1SLionel Sambuc	# 2. error if the whole shell does not exit (dsl's suggested behavior)
223*11be35a1SLionel Sambuc	#dcheck 'echo OK; (set -e; false); echo ERR' 'OK'
224*11be35a1SLionel Sambuc	#echeck 'echo OK; (set -e; false); echo ERR' 'OK'
225*11be35a1SLionel Sambuc
226*11be35a1SLionel Sambuc	# The current behavior of the shell is that it exits out as
227*11be35a1SLionel Sambuc	# far as -e is set and then stops. This is probably a
228*11be35a1SLionel Sambuc	# consequence of it handling () wrong, but it's a somewhat
229*11be35a1SLionel Sambuc	# curious compromise position between 1. and 2. above.
230*11be35a1SLionel Sambuc	dcheck '(set -e; (false; echo ERR); echo ERR); echo OK' 'OK'
231*11be35a1SLionel Sambuc	echeck '(set -e; (false; echo ERR); echo ERR); echo OK' 'OK'
232*11be35a1SLionel Sambuc
233*11be35a1SLionel Sambuc	# backquote expansion (PR bin/17514)
234*11be35a1SLionel Sambuc
235*11be35a1SLionel Sambuc	# correct
236*11be35a1SLionel Sambuc	#dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK'
237*11be35a1SLionel Sambuc	#dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK'
238*11be35a1SLionel Sambuc	#dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK'
239*11be35a1SLionel Sambuc	#dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK'
240*11be35a1SLionel Sambuc	# wrong current behavior
241*11be35a1SLionel Sambuc	dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK'
242*11be35a1SLionel Sambuc	dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK'
243*11be35a1SLionel Sambuc	dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK'
244*11be35a1SLionel Sambuc	dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'ERR ERR OK'
245*11be35a1SLionel Sambuc
246*11be35a1SLionel Sambuc	dcheck '(set -e; x=`false`; echo ERR); echo OK' 'OK'
247*11be35a1SLionel Sambuc	dcheck '(set -e; x=$(false); echo ERR); echo OK' 'OK'
248*11be35a1SLionel Sambuc	dcheck '(set -e; x=`exit 3`; echo ERR); echo OK' 'OK'
249*11be35a1SLionel Sambuc	dcheck '(set -e; x=$(exit 3); echo ERR); echo OK' 'OK'
250*11be35a1SLionel Sambuc
251*11be35a1SLionel Sambuc	# correct
252*11be35a1SLionel Sambuc	#echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK'
253*11be35a1SLionel Sambuc	#echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK'
254*11be35a1SLionel Sambuc	#echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK'
255*11be35a1SLionel Sambuc	#echeck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK'
256*11be35a1SLionel Sambuc
257*11be35a1SLionel Sambuc	# wrong current behavior
258*11be35a1SLionel Sambuc	echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK'
259*11be35a1SLionel Sambuc	echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK'
260*11be35a1SLionel Sambuc	echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK'
261*11be35a1SLionel Sambuc	echeck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'ERR ERR OK'
262*11be35a1SLionel Sambuc
263*11be35a1SLionel Sambuc	echeck '(set -e; x=`false`; echo ERR); echo OK' 'OK'
264*11be35a1SLionel Sambuc	echeck '(set -e; x=$(false); echo ERR); echo OK' 'OK'
265*11be35a1SLionel Sambuc	echeck '(set -e; x=`exit 3`; echo ERR); echo OK' 'OK'
266*11be35a1SLionel Sambuc	echeck '(set -e; x=$(exit 3); echo ERR); echo OK' 'OK'
267*11be35a1SLionel Sambuc
268*11be35a1SLionel Sambuc	# shift (PR bin/37493)
269*11be35a1SLionel Sambuc	# correct
270*11be35a1SLionel Sambuc	#dcheck '(set -e; shift || true; echo OK); echo OK' 'OK OK'
271*11be35a1SLionel Sambuc	#echeck '(set -e; shift || true; echo OK); echo OK' 'OK OK'
272*11be35a1SLionel Sambuc	# wrong current behavior
273*11be35a1SLionel Sambuc	dcheck '(set -e; shift || true; echo OK); echo OK' 'OK'
274*11be35a1SLionel Sambuc	echeck '(set -e; shift || true; echo OK); echo OK' 'OK'
275*11be35a1SLionel Sambuc
276*11be35a1SLionel Sambuc	# Done.
277*11be35a1SLionel Sambuc
278*11be35a1SLionel Sambuc	if [ "x$SH_FAILS" != x ]; then
279*11be35a1SLionel Sambuc	    printf '%-56s %-8s  %s\n' "Expression" "Result" "Should be"
280*11be35a1SLionel Sambuc	    echo "$SH_FAILS"
281*11be35a1SLionel Sambuc	    atf_fail "$failcount of $count failed cases"
282*11be35a1SLionel Sambuc	else
283*11be35a1SLionel Sambuc	    atf_pass
284*11be35a1SLionel Sambuc	fi
285*11be35a1SLionel Sambuc}
286*11be35a1SLionel Sambuc
287*11be35a1SLionel Sambucatf_init_test_cases() {
288*11be35a1SLionel Sambuc	atf_add_test_case all
289*11be35a1SLionel Sambuc}
290