From 95f9d6eb0e8b0e7f7d5f7c29069ee7c23977d94d Mon Sep 17 00:00:00 2001 From: kn Date: Fri, 14 Oct 2022 23:51:16 +0000 Subject: [PATCH] add two new errexit/trap tests, tweak wording both pass in bash and ksh93 from ports. our ksh fails for now, so mark them as expected fail. --- regress/bin/ksh/trap.t | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/regress/bin/ksh/trap.t b/regress/bin/ksh/trap.t index bdef549c4bc..59dde9b160a 100644 --- a/regress/bin/ksh/trap.t +++ b/regress/bin/ksh/trap.t @@ -1,4 +1,4 @@ -# $OpenBSD: trap.t,v 1.2 2022/10/14 22:56:13 kn Exp $ +# $OpenBSD: trap.t,v 1.3 2022/10/14 23:51:16 kn Exp $ # # Check that I/O redirection failure triggers the ERR trap. @@ -49,12 +49,15 @@ expected-exit: e != 0 --- # -# Check that the errexit option does not interfere with running traps. +# Check that the errexit option +# a) does not interfere with running traps and +# b) propagates a non-zero exit status from traps. +# Check that traps are run in the same order in which they were triggered. # name: EXIT-always-runs description: - Check that the EXIT trap runs under errexit even if the ERR trap failed. + Check that EXIT runs under errexit even if ERR failed. arguments: !-e! stdin: trap 'echo ERR ; false' ERR @@ -81,3 +84,35 @@ expected-stdout: EXIT expected-exit: e == 0 --- + + +name: errexit-aborts-EXIT +# XXX remove once bin/ksh/main.c r1.52 is backed out +expected-fail: yes +description: + Check that errexit makes EXIT exit early. +arguments: !-e! +stdin: + trap 'echo ERR' ERR + trap 'false ; echo EXIT' EXIT +expected-stdout: + ERR +expected-exit: e != 0 +--- + + +name: EXIT-triggers-ERR +# XXX remove once bin/ksh/main.c r1.52 is backed out *AND* and a new fix is in +expected-fail: yes +description: + Check that ERR runs under errexit if EXIT failed. +arguments: !-e! +stdin: + trap 'echo ERR' ERR + trap 'echo EXIT ; false' EXIT + true +expected-stdout: + EXIT + ERR +expected-exit: e != 0 + --- -- 2.20.1