mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-02 08:42:48 +00:00
sh: Use exitstatus instead of exerrno to pass EXEXEC status
No functional change is intended.
This commit is contained in:
parent
4aed5937db
commit
b5532964e7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=339822
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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 *);
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user