diff options
author | jilles <jilles@FreeBSD.org> | 2013-01-13 19:19:40 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2013-01-13 19:19:40 +0000 |
commit | 1af5c5cc5f617aaef7ab78705c5c70caea880cb1 (patch) | |
tree | 69e38a953148ba5a234ec291b11123361e88e213 /bin/sh/parser.c | |
parent | 247875210d7ec5d2e7810928c3c2fcfcbd68aa39 (diff) | |
download | FreeBSD-src-1af5c5cc5f617aaef7ab78705c5c70caea880cb1.zip FreeBSD-src-1af5c5cc5f617aaef7ab78705c5c70caea880cb1.tar.gz |
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 $?
Diffstat (limited to 'bin/sh/parser.c')
-rw-r--r-- | bin/sh/parser.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c index ef1aa36..a19ca31 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -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: |