Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: preventing the leading space in process substitution
- X-seq: zsh-workers 25643
- From: Peter Stephenson <pws@xxxxxxx>
- To: "Zsh Hackers' List" <zsh-workers@xxxxxxxxxx>
- Subject: Re: preventing the leading space in process substitution
- Date: Thu, 11 Sep 2008 14:05:05 +0100
- In-reply-to: <6cd6de210809110544u569838dk5a93a739fa267822@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: CSR
- References: <20080909144101.GA30693@xxxxxxxxxxxxxxxxxxxx> <200809101124.m8ABOlKI005063@xxxxxxxxxxxxxx> <080910074842.ZM19151@xxxxxxxxxxxxxxxxxxxxxx> <200809101510.m8AFAajX007203@xxxxxxxxxxxxxx> <080910090554.ZM19272@xxxxxxxxxxxxxxxxxxxxxx> <6cd6de210809101151q4d0a2a35p452fe656e0ee7dd5@xxxxxxxxxxxxxx> <20080911130005.7c5e2b7c@news01> <6cd6de210809110544u569838dk5a93a739fa267822@xxxxxxxxxxxxxx>
On Thu, 11 Sep 2008 08:44:07 -0400
"Rocky Bernstein" <rocky.bernstein@xxxxxxxxx> wrote:
> A gentle nudge on having trap DEBUG (if not other traps as well) inherited
> in subshells. ;-)
They are currently reset explicitly. I think for most traps that's to
avoid the subshell picking up a signal destined for the parent shell
(unless the trap has specifically been set in the subshell), but it's
possible Bart has detailed knowledge.
I can't see why we shouldn't keep the debug-related traps, ZERR and DEBUG,
alive in subshells. It doesn't look like the behaviour was ever
documented. Would anyone expect the current behaviour? I hadn't realised
until you pointed it out.
Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.112
diff -u -r1.112 builtins.yo
--- Doc/Zsh/builtins.yo 5 Sep 2008 09:05:22 -0000 1.112
+++ Doc/Zsh/builtins.yo 11 Sep 2008 13:01:02 -0000
@@ -1330,7 +1330,9 @@
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
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.149
diff -u -r1.149 exec.c
--- Src/exec.c 10 Sep 2008 15:57:17 -0000 1.149
+++ Src/exec.c 11 Sep 2008 13:01:02 -0000
@@ -869,7 +869,8 @@
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)
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author