From: Jonathan Nieder <jrnieder@gmail.com>
To: Eric Blake <eblake@redhat.com>
Cc: Herbert Xu <herbert@gondor.hengli.com.au>,
Gerrit Pape <pape@smarden.org>,
dash@vger.kernel.org, "Krzysztof A. Sobiecki" <sobkas@gmail.com>,
Jari Aalto <jari.aalto@cante.net>
Subject: [PATCH 3/3] [EXCEPTIONS] Eliminate global exerrno
Date: Wed, 6 Oct 2010 20:08:07 -0500 [thread overview]
Message-ID: <20101007010807.GE1276@burratino> (raw)
In-Reply-To: <20101007010241.GB1276@burratino>
Pass the exit status from the exec builtin through the exitstatus
global. This just eliminates a global variable; no noticeable
change is intended.
Based on v0.5.3~57 (Eliminated global exerrno, 2005-02-25).
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
That's the end of the series. Thanks for reading.
src/error.h | 1 -
src/eval.c | 8 ++++----
src/exec.c | 3 ++-
src/main.c | 2 --
4 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/error.h b/src/error.h
index 1bb6a82..15ccbe3 100644
--- a/src/error.h
+++ b/src/error.h
@@ -62,7 +62,6 @@ struct jmploc {
extern struct jmploc *handler;
extern int exception;
-extern int exerrno; /* error for EXEXEC */
/* exceptions */
#define EXINT 0 /* SIGINT received */
diff --git a/src/eval.c b/src/eval.c
index 5b8d36b..0406571 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -850,15 +850,15 @@ bail:
listsetvar(varlist.list, VEXPORT);
}
if (evalbltin(cmdentry.u.cmd, argc, argv, flags)) {
- int status;
int i;
i = exception;
if (i == EXEXIT)
goto raise;
-
- status = (i == EXINT) ? SIGINT + 128 : 2;
- exitstatus = status;
+ if (i == EXINT)
+ exitstatus = SIGINT + 128;
+ if (i == EXERROR)
+ exitstatus = 2;
if (i == EXINT || spclbltin > 0) {
raise:
diff --git a/src/exec.c b/src/exec.c
index 9525a16..42299ea 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -86,7 +86,6 @@ struct tblentry {
STATIC struct tblentry *cmdtable[CMDTABLESIZE];
STATIC int builtinloc = -1; /* index in path of %builtin, or -1 */
-int exerrno; /* Last exec error */
STATIC void tryexec(char *, char **, char **);
@@ -109,6 +108,7 @@ shellexec(char **argv, const char *path, int idx)
char *cmdname;
int e;
char **envp;
+ int exerrno;
envp = environment();
if (strchr(argv[0], '/') != NULL) {
@@ -138,6 +138,7 @@ shellexec(char **argv, const char *path, int idx)
exerrno = 2;
break;
}
+ exitstatus = exerrno;
TRACE(("shellexec failed for %s, errno %d, suppressint %d\n",
argv[0], e, suppressint ));
exerror(EXEXEC, "%s: %s", argv[0], errmsg(e, E_EXEC));
diff --git a/src/main.c b/src/main.c
index 5bc1a99..2bff956 100644
--- a/src/main.c
+++ b/src/main.c
@@ -115,8 +115,6 @@ main(int argc, char **argv)
e = exception;
if (e == EXERROR)
exitstatus = 2;
- else if (e == EXEXEC)
- exitstatus = exerrno;
s = state;
if (e == EXEXIT || s == 0 || iflag == 0 || shlvl)
--
1.7.2.3
next prev parent reply other threads:[~2010-10-07 1:11 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-05 16:06 debian patches to exit with code 127 for nonexistent/directory scripts Jilles Tjoelker
2010-06-08 10:19 ` Herbert Xu
2010-06-08 10:36 ` Cristian Ionescu-Idbohrn
2010-06-11 8:39 ` Herbert Xu
2010-06-14 9:54 ` [PATCH] [INPUT] exit 127 if command_file is given but doesn't exist Gerrit Pape
2010-06-28 6:53 ` Herbert Xu
2010-10-06 10:04 ` [PATCH] [OPTIONS] Use exit status 127 when the script to run does not exist Jonathan Nieder
2010-10-06 10:08 ` [PATCH] [INPUT] Catch attempts to run a directory as a script Jonathan Nieder
2010-10-06 10:29 ` Herbert Xu
2010-10-06 10:55 ` Jonathan Nieder
2010-10-06 12:18 ` Eric Blake
2010-10-06 12:31 ` Herbert Xu
2010-10-07 1:02 ` [PATCH 0/3] Fix exit status for 'exec nonexistent' and 'exec .' Jonathan Nieder
2010-10-07 1:03 ` [PATCH 1/3] [EXCEPTIONS] Stop documenting EXSHELLPROC Jonathan Nieder
2010-10-07 3:01 ` Herbert Xu
2010-10-07 3:04 ` Jonathan Nieder
2010-10-07 3:29 ` Herbert Xu
2010-10-07 3:39 ` [PATCH v2] " Jonathan Nieder
2010-11-28 12:47 ` Herbert Xu
2010-10-07 1:04 ` [PATCH 2/3] Revert "Eliminated global exerrno." Jonathan Nieder
2010-10-07 2:56 ` Herbert Xu
2010-10-07 3:35 ` Jonathan Nieder
2010-10-07 4:14 ` Herbert Xu
2010-10-07 4:37 ` Herbert Xu
2010-10-07 21:34 ` Jonathan Nieder
2010-11-28 12:45 ` Herbert Xu
2010-10-07 1:08 ` Jonathan Nieder [this message]
2010-10-07 3:00 ` [PATCH 3/3] [EXCEPTIONS] Eliminate global exerrno Herbert Xu
2010-11-28 12:06 ` [PATCH] [OPTIONS] Use exit status 127 when the script to run does not exist Herbert Xu
2010-11-28 12:24 ` Herbert Xu
2010-11-28 12:33 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101007010807.GE1276@burratino \
--to=jrnieder@gmail.com \
--cc=dash@vger.kernel.org \
--cc=eblake@redhat.com \
--cc=herbert@gondor.hengli.com.au \
--cc=jari.aalto@cante.net \
--cc=pape@smarden.org \
--cc=sobkas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.