summaryrefslogtreecommitdiffstats
path: root/bin/sh/eval.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-02-04 22:47:55 +0000
committerjilles <jilles@FreeBSD.org>2011-02-04 22:47:55 +0000
commit95ad413d4a493285a5560182fb10217819d7c357 (patch)
tree88fab75180accb5d4fe09924cbd01e047b9e4903 /bin/sh/eval.c
parent88f7b7c78b4285a838792e26cf3806ab40f879d2 (diff)
downloadFreeBSD-src-95ad413d4a493285a5560182fb10217819d7c357.zip
FreeBSD-src-95ad413d4a493285a5560182fb10217819d7c357.tar.gz
sh: Remove special code for shell scripts without magic number.
These are called "shell procedures" in the source. If execve() failed with [ENOEXEC], the shell would reinitialize itself and execute the program as a script. This requires a fair amount of code which is not frequently used (most scripts have a #! magic number). Therefore just execute a new instance of sh (_PATH_BSHELL) to run the script.
Diffstat (limited to 'bin/sh/eval.c')
-rw-r--r--bin/sh/eval.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 0bb5322..2d3f631 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -111,10 +111,6 @@ RESET {
loopnest = 0;
funcnest = 0;
}
-
-SHELLPROC {
- exitstatus = 0;
-}
#endif
@@ -732,7 +728,9 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
argc = 0;
for (sp = arglist.list ; sp ; sp = sp->next)
argc++;
- argv = stalloc(sizeof (char *) * (argc + 1));
+ /* Add one slot at the beginning for tryexec(). */
+ argv = stalloc(sizeof (char *) * (argc + 2));
+ argv++;
for (sp = arglist.list ; sp ; sp = sp->next) {
TRACE(("evalcommand arg: %s\n", sp->text));
@@ -927,14 +925,10 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
reffunc(cmdentry.u.func);
savehandler = handler;
if (setjmp(jmploc.loc)) {
- if (exception == EXSHELLPROC)
- freeparam(&saveparam);
- else {
- freeparam(&shellparam);
- shellparam = saveparam;
- if (exception == EXERROR || exception == EXEXEC)
- popredir();
- }
+ freeparam(&shellparam);
+ shellparam = saveparam;
+ if (exception == EXERROR || exception == EXEXEC)
+ popredir();
unreffunc(cmdentry.u.func);
poplocalvars();
localvars = savelocalvars;
@@ -1016,11 +1010,9 @@ cmddone:
out2 = &errout;
freestdout();
handler = savehandler;
- if (e != EXSHELLPROC) {
- commandname = savecmdname;
- if (jp)
- exitshell(exitstatus);
- }
+ commandname = savecmdname;
+ if (jp)
+ exitshell(exitstatus);
if (flags == EV_BACKCMD) {
backcmd->buf = memout.buf;
backcmd->nleft = memout.nextc - memout.buf;
OpenPOWER on IntegriCloud