summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-12-28 13:28:24 +0000
committerjilles <jilles@FreeBSD.org>2010-12-28 13:28:24 +0000
commit713ef02a1f782c52b5a7a985ce0f49312efd9a4d (patch)
tree1738ee903ef380fedf52a82c7ea4c2ac68689146 /bin/sh
parent5fb7e0486ccab134af174e9583417825e30f2f26 (diff)
downloadFreeBSD-src-713ef02a1f782c52b5a7a985ce0f49312efd9a4d.zip
FreeBSD-src-713ef02a1f782c52b5a7a985ce0f49312efd9a4d.tar.gz
sh: Make expansion errors in optimized command substitution non-fatal.
Command substitutions consisting of a single simple command are executed in the main shell process but this should be invisible apart from performance and very few exceptions such as $(trap).
Diffstat (limited to 'bin/sh')
-rw-r--r--bin/sh/eval.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 5bae2f2..596a86c 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -578,6 +578,8 @@ evalbackcmd(union node *n, struct backcmd *result)
int pip[2];
struct job *jp;
struct stackmark smark; /* unnecessary */
+ struct jmploc jmploc;
+ struct jmploc *savehandler;
setstackmark(&smark);
result->fd = -1;
@@ -590,7 +592,19 @@ evalbackcmd(union node *n, struct backcmd *result)
}
if (n->type == NCMD) {
exitstatus = oexitstatus;
- evalcommand(n, EV_BACKCMD, result);
+ savehandler = handler;
+ if (setjmp(jmploc.loc)) {
+ if (exception == EXERROR || exception == EXEXEC)
+ exitstatus = 2;
+ else if (exception != 0) {
+ handler = savehandler;
+ longjmp(handler->loc, 1);
+ }
+ } else {
+ handler = &jmploc;
+ evalcommand(n, EV_BACKCMD, result);
+ }
+ handler = savehandler;
} else {
exitstatus = 0;
if (pipe(pip) < 0)
OpenPOWER on IntegriCloud