1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-13 02:56:18 +02:00

19682: Don't run ZERR, DEBUG or EXIT traps inside other traps.

This commit is contained in:
Peter Stephenson 2004-03-25 10:07:12 +00:00
parent 8de7436fc0
commit 83b0fd3674
4 changed files with 40 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2004-03-25 Peter Stephenson <pws@csr.com>
* 19682: Doc/Zsh/builtins.yo, Etc/NEWS, Src/signals.c: Don't
run ZERR, DEBUG or EXIT traps inside other traps; caused confusion
and incompatibility.
2004-03-24 Peter Stephenson <pws@csr.com>
* 19674 plus unposted changes suggested in 19676:

View File

@ -1116,6 +1116,8 @@ 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.
The tt(trap) command with no arguments prints a list of commands
associated with each signal.

View File

@ -5,14 +5,19 @@ CHANGES FROM PREVIOUS VERSIONS OF ZSH
Changes since zsh version 4.2.0
-------------------------------
The zftp module supports ports following the hostname in the normal suffix
notation, `host:port'. This requires IPv6 colon-style addresses to be
specified in suitably quoted square brackets, for example:
- The zftp module supports ports following the hostname in the normal suffix
notation, `host:port'. This requires IPv6 colon-style addresses to be
specified in suitably quoted square brackets, for example:
zftp open '[f000::baaa]'
zftp open '[f000::baaa]:ftp'
(the two are equivalent).
(the two are equivalent).
- Special traps, those that don't correspond to signals, i.e. ZERR, DEBUG
and EXIT are no longer executed inside other traps. This caused
unnecessary confusion if, for example, both DEBUG and EXIT traps
were set. The new behaviour is more compatible with other shells.
New features between zsh versions 4.0 and 4.2

View File

@ -932,7 +932,10 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
int trapret = 0;
int obreaks = breaks;
int isfunc;
/* Are we already executing a trap? */
static int intrap;
/* if signal is being ignored or the trap function *
* is NULL, then return *
* *
@ -946,6 +949,24 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
if ((*sigtr & ZSIG_IGNORED) || !sigfn || errflag)
return;
/*
* Never execute special (synchronous) traps inside other traps.
* This can cause unexpected code execution when more than one
* of these is set.
*
* The down side is that it's harder to debug traps. I don't think
* that's a big issue.
*/
if (intrap) {
switch (sig) {
case SIGEXIT:
case SIGDEBUG:
case SIGZERR:
return;
}
}
intrap++;
*sigtr |= ZSIG_IGNORED;
lexsave();
@ -1023,6 +1044,7 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
if (*sigtr != ZSIG_IGNORED)
*sigtr &= ~ZSIG_IGNORED;
intrap--;
}
/* Standard call to execute a trap for a given signal. */