From 0d3a786b7cff90868a586e5e3a491b82589a236d Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Wed, 10 Oct 2018 11:17:58 +0100
Subject: 43669: ensure explicit exit status is used over implicit
---
Src/builtin.c | 4 ++--
Src/init.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
(limited to 'Src')
diff --git a/Src/builtin.c b/Src/builtin.c
index e01e035cc..8dcdcc024 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5723,7 +5723,7 @@ int exit_val;
void
realexit(void)
{
- exit(exit_val ? exit_val : lastval);
+ exit((shell_exiting || exit_pending) ? exit_val : lastval);
}
/* As realexit(), but call _exit instead */
@@ -5732,7 +5732,7 @@ realexit(void)
void
_realexit(void)
{
- _exit(exit_val ? exit_val : lastval);
+ _exit((shell_exiting || exit_pending) ? exit_val : lastval);
}
/* exit the shell. val is the return value of the shell. *
diff --git a/Src/init.c b/Src/init.c
index 838c2c2d1..cec914329 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1358,7 +1358,7 @@ init_misc(char *cmd, char *zsh_name)
bshin = fdopen(SHIN, "r");
execstring(cmd, 0, 1, "cmdarg");
stopmsg = 1;
- zexit(exit_val ? exit_val : lastval, 0);
+ zexit((exit_pending || shell_exiting) ? exit_val : lastval, 0);
}
if (interact && isset(RCS))
--
cgit 1.4.1