diff options
author | jilles <jilles@FreeBSD.org> | 2013-01-14 12:20:55 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2013-01-14 12:20:55 +0000 |
commit | d139340997182e1df37c94af9e42715cb2c00ed2 (patch) | |
tree | a074a51333e90bbde73c4bc3f4b482da8f98eb91 /bin/sh | |
parent | ee65990ea492afce93ac0eb4504b71c1a8f85b5d (diff) | |
download | FreeBSD-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/sh')
-rw-r--r-- | bin/sh/eval.c | 3 |
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); |