[openssh-commits] [openssh] 01/01: Improve compatibility of early exit trap handling.
git+noreply at mindrot.org
git+noreply at mindrot.org
Thu Jan 20 13:49:58 AEDT 2022
This is an automated email from the git hooks/post-receive script.
dtucker pushed a commit to branch master
in repository openssh.
commit 2e5cfed513e84444483baf1d8b31c40072b05103
Author: Darren Tucker <dtucker at dtucker.net>
Date: Thu Jan 20 13:26:27 2022 +1100
Improve compatibility of early exit trap handling.
Dash (as used by the github runners) has some differences in its trap
builtin:
- it doesn't have -p (which is fine, that's not in posix).
- it doesn't work in a subshell (which turns out to be in compliance
with posix, which means bash isn't).
- it doesn't work in a pipeline, ie "trap|cat" produces no output.
---
regress/test-exec.sh | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/regress/test-exec.sh b/regress/test-exec.sh
index 7aeead5c..15bdd084 100644
--- a/regress/test-exec.sh
+++ b/regress/test-exec.sh
@@ -724,10 +724,15 @@ if [ "x$USE_VALGRIND" != "x" ]; then
# their logs, but since the EXIT traps are not invoked until
# test-exec.sh exits, waiting here will deadlock.
# This is not very portable but then neither is valgrind itself.
- exithandler=$(trap -p | awk -F "'" '/EXIT$/{print $2}')
+ # As a bonus, dash (as used on the runners) has a "trap" that doesn't
+ # work in a pipeline (hence the temp file) or a subshell.
+ exithandler=""
+ trap >/tmp/trap.$$ && exithandler=$(cat /tmp/trap.$$ | \
+ awk -F "'" '/EXIT$/{print $2}')
+ rm -f /tmp/trap.$$
if [ "x${exithandler}" != "x" ]; then
verbose invoking EXIT trap handler early: ${exithandler}
- ${exithandler}
+ eval "${exithandler}"
trap '' EXIT
fi
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list