Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2018-11-14 21:31:46 +0300
committerBryan Drewery <bryan@shatow.net>2018-11-14 21:31:46 +0300
commit118f2013de428f67ea8b4f714168a91a48989423 (patch)
tree1c757b7ec2370298f63cfa403d7a56c0145b55a3 /external
parentb2b61783c7d82e1bef5d50096e79e4af469a8650 (diff)
Update sh from head r340284
Diffstat (limited to 'external')
-rw-r--r--external/sh/error.c21
-rw-r--r--external/sh/error.h9
-rw-r--r--external/sh/eval.c22
-rw-r--r--external/sh/exec.c14
-rw-r--r--external/sh/exec.h4
-rw-r--r--external/sh/jobs.c5
-rw-r--r--external/sh/main.c15
7 files changed, 34 insertions, 56 deletions
diff --git a/external/sh/error.c b/external/sh/error.c
index 7f184ac1..a2eeb70a 100644
--- a/external/sh/error.c
+++ b/external/sh/error.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95";
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/error.c 314436 2017-02-28 23:42:47Z imp $");
+__FBSDID("$FreeBSD: head/bin/sh/error.c 340284 2018-11-09 14:58:24Z jilles $");
/*
* Errors and exceptions.
@@ -67,7 +67,7 @@ volatile sig_atomic_t suppressint;
volatile sig_atomic_t intpending;
-static void exverror(int, const char *, va_list) __printf0like(2, 0) __dead2;
+static void verrorwithstatus(int, const char *, va_list) __printf0like(2, 0) __dead2;
/*
* Called to raise an exception. Since C doesn't include exceptions, we
@@ -154,7 +154,7 @@ warning(const char *msg, ...)
* formatting. It then raises the error exception.
*/
static void
-exverror(int cond, const char *msg, va_list ap)
+verrorwithstatus(int status, const char *msg, va_list ap)
{
/*
* An interrupt trumps an error. Certain places catch error
@@ -168,14 +168,17 @@ exverror(int cond, const char *msg, va_list ap)
#ifdef DEBUG
if (msg)
- TRACE(("exverror(%d, \"%s\") pid=%d\n", cond, msg, getpid()));
+ TRACE(("verrorwithstatus(%d, \"%s\") pid=%d\n",
+ status, msg, getpid()));
else
- TRACE(("exverror(%d, NULL) pid=%d\n", cond, getpid()));
+ TRACE(("verrorwithstatus(%d, NULL) pid=%d\n",
+ status, getpid()));
#endif
if (msg)
vwarning(msg, ap);
flushall();
- exraise(cond);
+ exitstatus = status;
+ exraise(EXERROR);
}
@@ -184,16 +187,16 @@ error(const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
- exverror(EXERROR, msg, ap);
+ verrorwithstatus(2, msg, ap);
va_end(ap);
}
void
-exerror(int cond, const char *msg, ...)
+errorwithstatus(int status, const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
- exverror(cond, msg, ap);
+ verrorwithstatus(status, msg, ap);
va_end(ap);
}
diff --git a/external/sh/error.h b/external/sh/error.h
index e962c4f2..d6a4368b 100644
--- a/external/sh/error.h
+++ b/external/sh/error.h
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* @(#)error.h 8.2 (Berkeley) 5/4/95
- * $FreeBSD: head/bin/sh/error.h 319591 2017-06-04 21:58:02Z jilles $
+ * $FreeBSD: head/bin/sh/error.h 340284 2018-11-09 14:58:24Z jilles $
*/
/*
@@ -55,9 +55,8 @@ extern volatile sig_atomic_t exception;
/* exceptions */
#define EXINT 0 /* SIGINT received */
-#define EXERROR 1 /* a generic error */
-#define EXEXEC 2 /* command execution failed */
-#define EXEXIT 3 /* call exitshell(exitstatus) */
+#define EXERROR 1 /* a generic error with exitstatus */
+#define EXEXIT 2 /* call exitshell(exitstatus) */
/*
@@ -83,7 +82,7 @@ void exraise(int) __dead2;
void onint(void) __dead2;
void warning(const char *, ...) __printflike(1, 2);
void error(const char *, ...) __printf0like(1, 2) __dead2;
-void exerror(int, const char *, ...) __printf0like(2, 3) __dead2;
+void errorwithstatus(int, const char *, ...) __printf0like(2, 3) __dead2;
/*
diff --git a/external/sh/eval.c b/external/sh/eval.c
index bb5f3ccc..362fd798 100644
--- a/external/sh/eval.c
+++ b/external/sh/eval.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/eval.c 327212 2017-12-26 16:23:18Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/eval.c 340284 2018-11-09 14:58:24Z jilles $");
#include <paths.h>
#include <signal.h>
@@ -466,12 +466,9 @@ evalredir(union node *n, int flags)
handler = savehandler;
e = exception;
popredir();
- if (e == EXERROR || e == EXEXEC) {
- if (in_redirect) {
- exitstatus = 2;
- FORCEINTON;
- return;
- }
+ if (e == EXERROR && in_redirect) {
+ FORCEINTON;
+ return;
}
longjmp(handler->loc, 1);
} else {
@@ -505,7 +502,7 @@ exphere(union node *redir, struct arglist *fn)
forcelocal++;
savehandler = handler;
if (setjmp(jmploc.loc))
- need_longjmp = exception != EXERROR && exception != EXEXEC;
+ need_longjmp = exception != EXERROR;
else {
handler = &jmploc;
expandarg(redir->nhere.doc, fn, 0);
@@ -669,8 +666,8 @@ evalbackcmd(union node *n, struct backcmd *result)
forcelocal++;
savehandler = handler;
if (setjmp(jmploc.loc)) {
- if (exception == EXERROR || exception == EXEXEC)
- exitstatus = 2;
+ if (exception == EXERROR)
+ /* nothing */;
else if (exception != 0) {
handler = savehandler;
forcelocal--;
@@ -1089,8 +1086,6 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
e = exception;
if (e == EXINT)
exitstatus = SIGINT+128;
- else if (e != EXEXIT)
- exitstatus = 2;
goto cmddone;
}
handler = &jmploc;
@@ -1139,8 +1134,7 @@ cmddone:
if (cmdentry.u.index != EXECCMD)
popredir();
if (e != -1) {
- if ((e != EXERROR && e != EXEXEC)
- || cmdentry.special)
+ if (e != EXERROR || cmdentry.special)
exraise(e);
popfilesupto(savetopfile);
if (flags != EV_BACKCMD)
diff --git a/external/sh/exec.c b/external/sh/exec.c
index 067455bf..c7896b1c 100644
--- a/external/sh/exec.c
+++ b/external/sh/exec.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95";
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/exec.c 336320 2018-07-15 21:55:17Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/exec.c 340284 2018-11-09 14:58:24Z jilles $");
#include <sys/types.h>
#include <sys/stat.h>
@@ -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 **);
@@ -134,13 +133,10 @@ shellexec(char **argv, char **envp, const char *path, int idx)
}
/* Map to POSIX errors */
- if (e == ENOENT || e == ENOTDIR) {
- exerrno = 127;
- exerror(EXEXEC, "%s: not found", argv[0]);
- } else {
- exerrno = 126;
- exerror(EXEXEC, "%s: %s", argv[0], strerror(e));
- }
+ if (e == ENOENT || e == ENOTDIR)
+ errorwithstatus(127, "%s: not found", argv[0]);
+ else
+ errorwithstatus(126, "%s: %s", argv[0], strerror(e));
}
diff --git a/external/sh/exec.h b/external/sh/exec.h
index d13907bd..79899edb 100644
--- a/external/sh/exec.h
+++ b/external/sh/exec.h
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* @(#)exec.h 8.3 (Berkeley) 6/8/95
- * $FreeBSD: head/bin/sh/exec.h 336320 2018-07-15 21:55:17Z jilles $
+ * $FreeBSD: head/bin/sh/exec.h 339822 2018-10-27 20:17:57Z jilles $
*/
/* values of cmdtype */
@@ -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/external/sh/jobs.c b/external/sh/jobs.c
index 358153bd..77699985 100644
--- a/external/sh/jobs.c
+++ b/external/sh/jobs.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/jobs.c 328818 2018-02-02 22:53:58Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/jobs.c 340284 2018-11-09 14:58:24Z jilles $");
#include <sys/ioctl.h>
#include <sys/param.h>
@@ -73,6 +73,7 @@ __FBSDID("$FreeBSD: head/bin/sh/jobs.c 328818 2018-02-02 22:53:58Z jilles $");
#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(exitstatus);
if (pip != NULL) {
close(pip[0]);
if (pip[1] != 1) {
diff --git a/external/sh/main.c b/external/sh/main.c
index 064662fa..585af7a6 100644
--- a/external/sh/main.c
+++ b/external/sh/main.c
@@ -44,7 +44,7 @@ static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/28/95";
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/main.c 336320 2018-07-15 21:55:17Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/main.c 340284 2018-11-09 14:58:24Z jilles $");
#include <stdio.h>
#include <signal.h>
@@ -105,19 +105,6 @@ main(int argc, char *argv[])
initcharset();
state = 0;
if (setjmp(main_handler.loc)) {
- switch (exception) {
- case EXEXEC:
- exitstatus = exerrno;
- break;
-
- case EXERROR:
- exitstatus = 2;
- break;
-
- default:
- break;
- }
-
if (state == 0 || iflag == 0 || ! rootshell ||
exception == EXEXIT)
exitshell(exitstatus);