about summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2016-02-25 14:20:26 +0000
committerPeter Stephenson <pws@zsh.org>2016-02-25 14:20:26 +0000
commitc55d8551718bcf2fc7661c31c13e934060a5f1a7 (patch)
treeea5362983b67d3c471e54beae6495d928d81eb21 /Test
parent3195003cde3287300b75903f5266721bd04e0e31 (diff)
downloadzsh-c55d8551718bcf2fc7661c31c13e934060a5f1a7.tar.gz
zsh-c55d8551718bcf2fc7661c31c13e934060a5f1a7.tar.xz
zsh-c55d8551718bcf2fc7661c31c13e934060a5f1a7.zip
38024: Improve POSIX and native EXIT traps compatibility.
Allow a nested function trap to leave save and restore a POSIX
trap.

Still fails if the POSIX trap was defined in a function.
Diffstat (limited to 'Test')
-rw-r--r--Test/C03traps.ztst17
1 files changed, 17 insertions, 0 deletions
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index d8183a428..f4466b556 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -419,6 +419,23 @@
 >end of program
 >EXIT TRAP TRIGGERED
 
+   (cd ..; $ZTST_exe -fc '
+     echo entering program
+     emulate sh -c '\''trap "echo POSIX exit trap triggered" EXIT'\''
+     fn() {
+        trap "echo native zsh function-local exit trap triggered" EXIT
+        echo entering native zsh function
+     }
+     fn
+     echo exiting program
+   ')
+0:POSX EXIT trap can have nested native mode EXIT trap
+>entering program
+>entering native zsh function
+>native zsh function-local exit trap triggered
+>exiting program
+>POSIX exit trap triggered
+
    (set -e
     printf "a\nb\n" | while read line
     do