From db3614900602b51edd79ae8c1308b8665de9f913 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Sat, 15 May 2021 13:59:17 -0700
Subject: users/26742: break out of surrounding shell loops when exit is called
from an exit hook
---
Src/builtin.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
(limited to 'Src/builtin.c')
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 */
--
cgit 1.4.1