Date: Sat, 27 Oct 2018 20:17:57 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339822 - head/bin/sh Message-ID: <201810272017.w9RKHvrA018572@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sat Oct 27 20:17:57 2018 New Revision: 339822 URL: https://svnweb.freebsd.org/changeset/base/339822 Log: sh: Use exitstatus instead of exerrno to pass EXEXEC status No functional change is intended. Modified: head/bin/sh/eval.c head/bin/sh/exec.c head/bin/sh/exec.h head/bin/sh/jobs.c head/bin/sh/main.c Modified: head/bin/sh/eval.c ============================================================================== --- head/bin/sh/eval.c Sat Oct 27 19:08:06 2018 (r339821) +++ head/bin/sh/eval.c Sat Oct 27 20:17:57 2018 (r339822) @@ -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 e = exception; if (e == EXINT) exitstatus = SIGINT+128; - else if (e != EXEXIT) + else if (e != EXEXEC && e != EXEXIT) exitstatus = 2; goto cmddone; } Modified: head/bin/sh/exec.c ============================================================================== --- head/bin/sh/exec.c Sat Oct 27 19:08:06 2018 (r339821) +++ head/bin/sh/exec.c Sat Oct 27 20:17:57 2018 (r339822) @@ -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, /* 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)); } } Modified: head/bin/sh/exec.h ============================================================================== --- head/bin/sh/exec.h Sat Oct 27 19:08:06 2018 (r339821) +++ head/bin/sh/exec.h Sat Oct 27 20:17:57 2018 (r339822) @@ -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 *); Modified: head/bin/sh/jobs.c ============================================================================== --- head/bin/sh/jobs.c Sat Oct 27 19:08:06 2018 (r339821) +++ head/bin/sh/jobs.c Sat Oct 27 20:17:57 2018 (r339822) @@ -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 **env 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) { Modified: head/bin/sh/main.c ============================================================================== --- head/bin/sh/main.c Sat Oct 27 19:08:06 2018 (r339821) +++ head/bin/sh/main.c Sat Oct 27 20:17:57 2018 (r339822) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201810272017.w9RKHvrA018572>