summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2021-05-15 13:59:17 -0700
committerBart Schaefer <schaefer@ipost.com>2021-05-15 13:59:17 -0700
commitdb3614900602b51edd79ae8c1308b8665de9f913 (patch)
tree0cdc7c8235fb7edb289bc651f28d29171c3d68a2
parente4bd6dc8182d7aa1c28058450db08e0a4dd41e90 (diff)
downloadzsh-db3614900602b51edd79ae8c1308b8665de9f913.tar.gz
zsh-db3614900602b51edd79ae8c1308b8665de9f913.zip
users/26742: break out of surrounding shell loops when exit is called from an exit hook
-rw-r--r--ChangeLog3
-rw-r--r--Src/builtin.c5
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 38f18a4b9..8e241fa6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2021-05-15 Bart Schaefer <schaefer@zsh.org>
+ * Peter Stephenson: users/26742: Src/builtin.c: break out of
+ surrounding shell loops when "exit" is called from an exit hook
+
* users/26736: Src/Zle/zle_main.c: avoid infinite loop in getbyte
when read -q is called from exit hook
diff --git a/Src/builtin.c b/Src/builtin.c
index b7ceefd55..a29eb49e4 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5828,8 +5828,11 @@ zexit(int val, enum zexit_t from_where)
* a later value always overrides an earlier.
*/
exit_val = val;
- if (shell_exiting == -1)
+ if (shell_exiting == -1) {
+ retflag = 1;
+ breaks = loops;
return;
+ }
if (isset(MONITOR) && !stopmsg && from_where != ZEXIT_SIGNAL) {
scanjobs(); /* check if jobs need printing */