From owner-svn-src-head@freebsd.org Sat Oct 27 20:17:59 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F079610D226A; Sat, 27 Oct 2018 20:17:58 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 953E079762; Sat, 27 Oct 2018 20:17:58 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 70A3A1514B; Sat, 27 Oct 2018 20:17:58 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9RKHwHX018577; Sat, 27 Oct 2018 20:17:58 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9RKHvrA018572; Sat, 27 Oct 2018 20:17:57 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201810272017.w9RKHvrA018572@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sat, 27 Oct 2018 20:17:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339822 - head/bin/sh X-SVN-Group: head X-SVN-Commit-Author: jilles X-SVN-Commit-Paths: head/bin/sh X-SVN-Commit-Revision: 339822 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Oct 2018 20:17:59 -0000 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;