[git commit] ash: [BUILTIN] Use EXEXIT in place of EXEXEC

Denys Vlasenko vda.linux at googlemail.com
Tue Oct 25 15:24:25 UTC 2016


commit: https://git.busybox.net/busybox/commit/?id=061a09091f21f8e2d3ac61cb1a5f8c919ddce26e
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Upstream commit:

    Date: Sun, 28 Nov 2010 20:44:37 +0800
    [BUILTIN] Use EXEXIT in place of EXEXEC

    The intended semantics of EXEXEC are identical to EXEXIT, so
    simplify by using EXEXIT directly.

    Functional change: in edge cases (exec within a trap handler),
    this causes the exit status from exec not to be clobbered.
    For example, without this patch:

     $ sh -c 'trap "exec nonexistent" EXIT'; echo $?
     exec: 1: nonexistent: not found
     0

    And with it:

     $ sh -c 'trap "exec nonexistent" EXIT'; echo $?
     exec: 1: nonexistent: not found
     127

    Signed-off-by: Jonathan Nieder <jrnieder at gmail.com>
    Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>

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

diff --git a/shell/ash.c b/shell/ash.c
index 9798a96..29d1d57 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -302,7 +302,6 @@ struct globals_misc {
 #define EXINT 0         /* SIGINT received */
 #define EXERROR 1       /* a generic error */
 #define EXSHELLPROC 2   /* execute a shell procedure */
-#define EXEXEC 3        /* command execution failed */
 #define EXEXIT 4        /* exit the shell */
 #define EXSIG 5         /* trapped signal in wait(1) */
 
@@ -7618,7 +7617,7 @@ shellexec(char **argv, const char *path, int idx)
 	exitstatus = exerrno;
 	TRACE(("shellexec failed for %s, errno %d, suppress_int %d\n",
 		argv[0], e, suppress_int));
-	ash_msg_and_raise(EXEXEC, "%s: %s", argv[0], errmsg(e, "not found"));
+	ash_msg_and_raise(EXEXIT, "%s: %s", argv[0], errmsg(e, "not found"));
 	/* NOTREACHED */
 }
 
@@ -9635,7 +9634,7 @@ evalcommand(union node *cmd, int flags)
 		if (evalbltin(cmdentry.u.cmd, argc, argv, flags)) {
 			int exit_status;
 			int i = exception_type;
-			if (i == EXEXIT || i == EXEXEC)
+			if (i == EXEXIT)
 				goto raise;
 			exit_status = 2;
 			if (i == EXINT)


More information about the busybox-cvs mailing list