diff options
author | Bart Schaefer <schaefer@zsh.org> | 2022-04-14 16:31:50 -0700 |
---|---|---|
committer | Bart Schaefer <schaefer@zsh.org> | 2022-04-14 16:31:50 -0700 |
commit | d24d7242fecec5a6d9db6f27f7439281dfa17021 (patch) | |
tree | 6880a1208316f0e73479282a462f7144fc16d5a6 | |
parent | 0ad3b11a133d44343a6474ac40b5354d43d54c5d (diff) | |
download | zsh-d24d7242fecec5a6d9db6f27f7439281dfa17021.tar.gz zsh-d24d7242fecec5a6d9db6f27f7439281dfa17021.tar.xz zsh-d24d7242fecec5a6d9db6f27f7439281dfa17021.zip |
50068: 'exit' in trap causes calling function to return
-rw-r--r-- | Etc/BUGS | 3 | ||||
-rw-r--r-- | Src/builtin.c | 2 | ||||
-rw-r--r-- | Test/C03traps.ztst | 2 |
3 files changed, 3 insertions, 4 deletions
diff --git a/Etc/BUGS b/Etc/BUGS index 5624fb24d..3121fc9fa 100644 --- a/Etc/BUGS +++ b/Etc/BUGS @@ -30,9 +30,6 @@ skipped when STTY=... is set for that command ------------------------------------------------------------------------ 42609: :|: =(hang) ------------------------------------------------------------------------ -44007 - Martijn - exit in trap executes rest of function -See test case in Test/C03traps.ztst. ------------------------------------------------------------------------- 44133 debian #924736 (partial patch in 44134) three setopts following ` #` ------------------------------------------------------------------------ 44850 terminal issues with continuation markers diff --git a/Src/builtin.c b/Src/builtin.c index 8ef678b22..b93466ba5 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5720,6 +5720,8 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func) * a bad job. */ if (stopmsg || (zexit(0, ZEXIT_DEFERRED), !stopmsg)) { + if (trap_state) + trap_state = TRAP_STATE_FORCE_RETURN; retflag = 1; breaks = loops; exit_pending = 1; diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst index 6f84e5db2..3bd2958cb 100644 --- a/Test/C03traps.ztst +++ b/Test/C03traps.ztst @@ -901,7 +901,7 @@ F:Must be tested with a top-level script rather than source or function fn trap1 trap2 echo out2 ' --f:(workers/44007) function execution continues after 'exit' in trap +-:(workers/44007) function execution continues after 'exit' in trap >out1 >fn1 >trap1 |