1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

sh: Pass $? to command substitution containing compound/multiple commands.

Example:
  false; echo $(echo $?; :)
This commit is contained in:
Jilles Tjoelker 2013-01-14 12:20:55 +00:00
parent 1cc20081df
commit 925420d09c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=245422
2 changed files with 6 additions and 2 deletions

View File

@ -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);

View File

@ -0,0 +1,5 @@
# $FreeBSD$
f() { return 3; }
f
[ `echo $?; :` = 3 ]