sh: Don't lose $? when backquoted command ends with semicolon or newline.

An empty simple command was added and overwrote the exit status with 0.

This affects `...` but not $(...).

Example:
  v=`false;`; echo $?
This commit is contained in:
Jilles Tjoelker 2013-01-13 19:19:40 +00:00
parent 6a347d023b
commit 2c090c7168
3 changed files with 12 additions and 1 deletions

View File

@ -286,7 +286,8 @@ list(int nlflag, int erflag)
tokpushback++;
}
checkkwd = CHKNL | CHKKWD | CHKALIAS;
if (!nlflag && !erflag && tokendlist[peektoken()])
if (!nlflag && (erflag ? peektoken() == TEOF :
tokendlist[peektoken()]))
return ntop;
break;
case TEOF:

View File

@ -0,0 +1,5 @@
# $FreeBSD$
! v=`false
`

View File

@ -0,0 +1,5 @@
# $FreeBSD$
! v=`false;
`