[git commit] ash: main: Only set savestatus in exitcmd

Denys Vlasenko vda.linux at googlemail.com
Sun Feb 16 18:14:45 UTC 2020


commit: https://git.busybox.net/busybox/commit/?id=970470e235fd2a00d4b020378ddccf769ce534ec
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Upstream commit:

    Date: Sat, 19 May 2018 02:39:38 +0800
    main: Only set savestatus in exitcmd

    Currently exitcmd sets exitstatus and then savestatus if the latter
    was previously set.  In fact, as exitcmd always raises an exception
    and will either end up in the setjmp call in main() or exitshell(),
    where exitstatus is always replaced by savestatus if set, we only
    need to set savestatus.

    Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/shell/ash.c b/shell/ash.c
index 270a338d9..db7dffc72 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13427,13 +13427,8 @@ exitcmd(int argc UNUSED_PARAM, char **argv)
 	if (stoppedjobs())
 		return 0;
 
-	if (argv[1]) {
-		int status = number(argv[1]);
-
-		exitstatus = status;
-		if (savestatus >= 0)
-			savestatus = status;
-	}
+	if (argv[1])
+		savestatus = number(argv[1]);
 
 	raise_exception(EXEXIT);
 	/* NOTREACHED */


More information about the busybox-cvs mailing list