summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-01-14 12:20:55 +0000
committerjilles <jilles@FreeBSD.org>2013-01-14 12:20:55 +0000
commitd139340997182e1df37c94af9e42715cb2c00ed2 (patch)
treea074a51333e90bbde73c4bc3f4b482da8f98eb91 /bin
parentee65990ea492afce93ac0eb4504b71c1a8f85b5d (diff)
downloadFreeBSD-src-d139340997182e1df37c94af9e42715cb2c00ed2.zip
FreeBSD-src-d139340997182e1df37c94af9e42715cb2c00ed2.tar.gz
sh: Pass $? to command substitution containing compound/multiple commands.
Example: false; echo $(echo $?; :)
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/eval.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 2e1315e..98261e9 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -624,8 +624,8 @@ evalbackcmd(union node *n, struct backcmd *result)
exitstatus = 0;
goto out;
}
+ exitstatus = oexitstatus;
if (is_valid_fast_cmdsubst(n)) {
- exitstatus = oexitstatus;
savelocalvars = localvars;
localvars = NULL;
forcelocal++;
@@ -649,7 +649,6 @@ evalbackcmd(union node *n, struct backcmd *result)
poplocalvars();
localvars = savelocalvars;
} else {
- exitstatus = 0;
if (pipe(pip) < 0)
error("Pipe call failed: %s", strerror(errno));
jp = makejob(n, 1);
OpenPOWER on IntegriCloud