diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2018-10-27 20:17:57 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2018-10-27 20:17:57 +0000 |
commit | b5532964e74ae1028c6f3aa5257f4af52251154c (patch) | |
tree | 601ca05c6278132523819173f73a5feb79ef9c83 | |
parent | 4aed5937db13b9d52904d06c585d189fe1c4bc8f (diff) |
Notes
-rw-r--r-- | bin/sh/eval.c | 9 | ||||
-rw-r--r-- | bin/sh/exec.c | 5 | ||||
-rw-r--r-- | bin/sh/exec.h | 2 | ||||
-rw-r--r-- | bin/sh/jobs.c | 3 | ||||
-rw-r--r-- | bin/sh/main.c | 4 |
5 files changed, 10 insertions, 13 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 6adc3ac6426d..c98077f41672 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -468,7 +468,8 @@ evalredir(union node *n, int flags) popredir(); if (e == EXERROR || e == EXEXEC) { if (in_redirect) { - exitstatus = 2; + if (e == EXERROR) + exitstatus = 2; FORCEINTON; return; } @@ -669,8 +670,10 @@ evalbackcmd(union node *n, struct backcmd *result) forcelocal++; savehandler = handler; if (setjmp(jmploc.loc)) { - if (exception == EXERROR || exception == EXEXEC) + if (exception == EXERROR) exitstatus = 2; + else if (exception == EXEXEC) + /* nothing */; else if (exception != 0) { handler = savehandler; forcelocal--; @@ -1089,7 +1092,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) e = exception; if (e == EXINT) exitstatus = SIGINT+128; - else if (e != EXEXIT) + else if (e != EXEXEC && e != EXEXIT) exitstatus = 2; goto cmddone; } diff --git a/bin/sh/exec.c b/bin/sh/exec.c index 95bf22a4a9f9..6bed44e6d3fc 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -91,7 +91,6 @@ struct tblentry { static struct tblentry *cmdtable[CMDTABLESIZE]; static int cmdtable_cd = 0; /* cmdtable contains cd-dependent entries */ -int exerrno = 0; /* Last exec error */ static void tryexec(char *, char **, char **); @@ -135,10 +134,10 @@ shellexec(char **argv, char **envp, const char *path, int idx) /* Map to POSIX errors */ if (e == ENOENT || e == ENOTDIR) { - exerrno = 127; + exitstatus = 127; exerror(EXEXEC, "%s: not found", argv[0]); } else { - exerrno = 126; + exitstatus = 126; exerror(EXEXEC, "%s: %s", argv[0], strerror(e)); } } diff --git a/bin/sh/exec.h b/bin/sh/exec.h index d7e8285fe362..03e7e6ab0b0c 100644 --- a/bin/sh/exec.h +++ b/bin/sh/exec.h @@ -61,8 +61,6 @@ struct cmdentry { #define DO_ERR 0x01 /* prints errors */ #define DO_NOFUNC 0x02 /* don't return shell functions, for command */ -extern int exerrno; /* last exec error */ - void shellexec(char **, char **, const char *, int) __dead2; char *padvance(const char **, const char **, const char *); void find_command(const char *, struct cmdentry *, int, const char *); diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 3e6da5fb9ad0..23abcc56d202 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include "mystring.h" #include "var.h" #include "builtins.h" +#include "eval.h" /* @@ -1005,7 +1006,7 @@ vforkexecshell(struct job *jp, char **argv, char **envp, const char *path, int i if (pid == 0) { TRACE(("Child shell %d\n", (int)getpid())); if (setjmp(jmploc.loc)) - _exit(exception == EXEXEC ? exerrno : 2); + _exit(exception == EXEXEC ? exitstatus : 2); if (pip != NULL) { close(pip[0]); if (pip[1] != 1) { diff --git a/bin/sh/main.c b/bin/sh/main.c index 5cf63815591a..7a15513dfe28 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -106,10 +106,6 @@ main(int argc, char *argv[]) state = 0; if (setjmp(main_handler.loc)) { switch (exception) { - case EXEXEC: - exitstatus = exerrno; - break; - case EXERROR: exitstatus = 2; break; |