From ab74c86edb30fa04fda5fe7fa01e404334f7c2b0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 17 Feb 2016 10:40:55 +0000 Subject: 37999: Sticky behaviour of EXIT traps. They now have POSIX or non-POSIX behaviour based on the setting of POSIX_TRAPS where the trap was defined, rather than where the trap would (or would not) be executed. Tweaks possible. --- Test/C03traps.ztst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Test/C03traps.ztst') diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst index 4b2843a47..d8183a428 100644 --- a/Test/C03traps.ztst +++ b/Test/C03traps.ztst @@ -399,6 +399,26 @@ >} >No, really exited + (cd ..; $ZTST_exe -fc 'unsetopt posixtraps; + echo start program + emulate sh -c '\''testfn() { + echo start function + set -o | grep posixtraps + trap "echo EXIT TRAP TRIGGERED" EXIT + echo end function + }'\'' + testfn + echo program continuing + echo end of program') +0:POSIX_TRAPS effect on EXIT trap is sticky +>start program +>start function +>noposixtraps off +>end function +>program continuing +>end of program +>EXIT TRAP TRIGGERED + (set -e printf "a\nb\n" | while read line do -- cgit 1.4.1