diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2010-11-28 20:44:37 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2010-11-28 20:44:37 +0800 |
commit | 8949a86cfe5d1daf2f46b5cd6b3bb73f78db2f31 (patch) | |
tree | 2f0725e393c4cefc62866dfe3c15f0497ca4c667 | |
parent | [INPUT] Use exit status 127 when the script to run does not exist (diff) | |
download | dash-8949a86cfe5d1daf2f46b5cd6b3bb73f78db2f31.tar.gz dash-8949a86cfe5d1daf2f46b5cd6b3bb73f78db2f31.zip |
[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@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/error.h | 1 | ||||
-rw-r--r-- | src/eval.c | 2 | ||||
-rw-r--r-- | src/exec.c | 2 |
4 files changed, 6 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog index a18838c..ac722c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-11-28 Jonathan Nieder <jrnieder@gmail.com> + + * Use EXEXIT in place of EXEXEC. + 2010-11-28 Gerrit Pape <pape@smarden.org> * Use exit status 127 when the script to run does not exist. diff --git a/src/error.h b/src/error.h index 3162e15..ad1e55b 100644 --- a/src/error.h +++ b/src/error.h @@ -67,7 +67,6 @@ extern int exception; #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 */ diff --git a/src/eval.c b/src/eval.c index 013a8dd..64aabb1 100644 --- a/src/eval.c +++ b/src/eval.c @@ -862,7 +862,7 @@ bail: int i; i = exception; - if (i == EXEXIT || i == EXEXEC) + if (i == EXEXIT) goto raise; status = (i == EXINT) ? SIGINT + 128 : 2; diff --git a/src/exec.c b/src/exec.c index 42299ea..b273420 100644 --- a/src/exec.c +++ b/src/exec.c @@ -141,7 +141,7 @@ shellexec(char **argv, const char *path, int idx) exitstatus = exerrno; TRACE(("shellexec failed for %s, errno %d, suppressint %d\n", argv[0], e, suppressint )); - exerror(EXEXEC, "%s: %s", argv[0], errmsg(e, E_EXEC)); + exerror(EXEXIT, "%s: %s", argv[0], errmsg(e, E_EXEC)); /* NOTREACHED */ } |