diff options
author | Klemens Nanni <kn@cvs.openbsd.org> | 2022-10-14 22:56:14 +0000 |
---|---|---|
committer | Klemens Nanni <kn@cvs.openbsd.org> | 2022-10-14 22:56:14 +0000 |
commit | d110bb39da821e7d7790f6982e2eaf093dbba569 (patch) | |
tree | a8f0fdc02a58c21a016d0b6d1d5732c7595a61cb | |
parent | ee013d40d5b673c74b162e4da75bca0ec6858a78 (diff) |
add two new errexit/trap tests
both behave the same with our ksh, bash and ksh93 from ports.
-rw-r--r-- | regress/bin/ksh/trap.t | 36 |
1 files changed, 35 insertions, 1 deletions
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 +--- |