diff options
author | Peter Stephenson <pws@zsh.org> | 2014-03-14 12:52:41 +0000 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2014-03-14 12:52:41 +0000 |
commit | a06cd1766afdbb74ec97e650f0bd945a78a8fdc8 (patch) | |
tree | defd7cb3c1f3287d68873b9b787dfd5572b83e3c /Src/signals.c | |
parent | 89c2342dd8d1bfb8e907b397a83e273553f1ad62 (diff) | |
download | zsh-a06cd1766afdbb74ec97e650f0bd945a78a8fdc8.tar.gz zsh-a06cd1766afdbb74ec97e650f0bd945a78a8fdc8.tar.xz zsh-a06cd1766afdbb74ec97e650f0bd945a78a8fdc8.zip |
32479: POSIXTRAPS and implicit return values.
With POSIXTRAPS never propagate implicit return value. In any case if not forcing a return value don't use lastval from within the trap, use the one from the surrounding code.
Diffstat (limited to 'Src/signals.c')
-rw-r--r-- | Src/signals.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Src/signals.c b/Src/signals.c index c8f5fbcca..a6eb8038b 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -1155,6 +1155,7 @@ dotrapargs(int sig, int *sigtr, void *sigfn) char *name, num[4]; int obreaks = breaks; int oretflag = retflag; + int olastval = lastval; int isfunc; int traperr, new_trap_state, new_trap_return; @@ -1261,6 +1262,13 @@ dotrapargs(int sig, int *sigtr, void *sigfn) } else { if (traperr && !EMULATION(EMULATE_SH)) lastval = 1; + else { + /* + * With no explicit forced return, we keep the + * lastval from before the trap ran. + */ + lastval = olastval; + } if (try_tryflag) errflag = traperr; breaks += obreaks; |