From 11cd34e8739ed776c15205e440155bb6f262eb9c Mon Sep 17 00:00:00 2001 From: kn Date: Fri, 14 Oct 2022 22:56:13 +0000 Subject: [PATCH] add two new errexit/trap tests both behave the same with our ksh, bash and ksh93 from ports. --- regress/bin/ksh/trap.t | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/regress/bin/ksh/trap.t b/regress/bin/ksh/trap.t index 624f37af902..bdef549c4bc 100644 --- a/regress/bin/ksh/trap.t +++ b/regress/bin/ksh/trap.t @@ -1,4 +1,4 @@ -# $OpenBSD: trap.t,v 1.1 2022/10/10 14:57:48 kn Exp $ +# $OpenBSD: trap.t,v 1.2 2022/10/14 22:56:13 kn Exp $ # # Check that I/O redirection failure triggers the ERR trap. @@ -47,3 +47,37 @@ expected-stderr-pattern: /Is a directory/ expected-exit: e != 0 --- + +# +# Check that the errexit option does not interfere with running traps. +# + +name: EXIT-always-runs +description: + Check that the EXIT trap runs under errexit even if the ERR trap failed. +arguments: !-e! +stdin: + trap 'echo ERR ; false' ERR + trap 'echo EXIT' EXIT + false +expected-stdout: + ERR + EXIT +expected-exit: e != 0 +--- + + +name: signal-handling-is-no-error +description: + Check that gracefully handling a signal is not treated as error. +arguments: !-e! +stdin: + trap 'echo ERR' ERR + trap 'echo EXIT' EXIT + trap 'echo USR1' USR1 + kill -USR1 $$ +expected-stdout: + USR1 + EXIT +expected-exit: e == 0 +--- -- 2.20.1