From d139340997182e1df37c94af9e42715cb2c00ed2 Mon Sep 17 00:00:00 2001 From: jilles Date: Mon, 14 Jan 2013 12:20:55 +0000 Subject: sh: Pass $? to command substitution containing compound/multiple commands. Example: false; echo $(echo $?; :) --- bin/sh/eval.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin/sh/eval.c') 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); -- cgit v1.1