summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-01-13 19:19:40 +0000
committerjilles <jilles@FreeBSD.org>2013-01-13 19:19:40 +0000
commit1af5c5cc5f617aaef7ab78705c5c70caea880cb1 (patch)
tree69e38a953148ba5a234ec291b11123361e88e213 /bin/sh
parent247875210d7ec5d2e7810928c3c2fcfcbd68aa39 (diff)
downloadFreeBSD-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')
-rw-r--r--bin/sh/parser.c3
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:
OpenPOWER on IntegriCloud