about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Doc/Zsh/builtins.yo4
-rw-r--r--Src/exec.c3
3 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f2929793f..a370973ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2008-09-11  Peter Stephenson  <pws@csr.com>
 
+	* 25643: Doc/Zsh/builtins.yo, Src/exec.c: keep DEBUG and ZERR
+	traps in subshells.
+
 	* 25641: add option (NO_)MULTI_FUNC_DEF to turn off "foo1
 	foo2...()" function definitions.
 
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index c47ae49e7..8317c9547 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1330,7 +1330,9 @@ If var(sig) is tt(0) or tt(EXIT)
 and the tt(trap) statement is not executed inside the body of a function,
 then the command var(arg) is executed when the shell terminates.
 
-tt(ZERR), tt(DEBUG), and tt(EXIT) traps are not executed inside other traps.
+tt(ZERR), tt(DEBUG), and tt(EXIT) traps are not executed inside other
+traps.  tt(ZERR) and tt(DEBUG) traps are kept within subshells, while
+other traps are reset.
 
 Note that traps defined with the tt(trap) builtin are slightly different
 from those defined as `tt(TRAP)var(NAL) () { ... }', as the latter have
diff --git a/Src/exec.c b/Src/exec.c
index a78212888..f1c5788bf 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -869,7 +869,8 @@ entersubsh(int flags)
 
     if (!(flags & ESUB_KEEPTRAP))
 	for (sig = 0; sig < VSIGCOUNT; sig++)
-	    if (!(sigtrapped[sig] & ZSIG_FUNC))
+	    if (!(sigtrapped[sig] & ZSIG_FUNC) &&
+		sig != SIGDEBUG && sig != SIGZERR)
 		unsettrap(sig);
     monitor = isset(MONITOR);
     if (flags & ESUB_NOMONITOR)