summaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenys Vlasenko2021-09-08 01:43:12 +0200
committerDenys Vlasenko2021-09-08 01:43:12 +0200
commit8c68ae8416c8b54222eb3cd1d4908a570147e134 (patch)
tree0da34e8659371340b1dfd5984043be00bde96ebb /shell/ash.c
parentc54025612711a6b1997efd99206b9fbcaa5a29cf (diff)
downloadbusybox-8c68ae8416c8b54222eb3cd1d4908a570147e134.zip
busybox-8c68ae8416c8b54222eb3cd1d4908a570147e134.tar.gz
ash: parser: Fix alias expansion after heredoc or newlines
Upstream commit: Date: Wed, 29 Apr 2020 00:19:59 +1000 parser: Fix alias expansion after heredoc or newlines This script should print OK: alias a="case x in " b=x a b) echo BAD;; esac alias BEGIN={ END=} BEGIN cat <<- EOF > /dev/null $(:) EOF END : <<- EOF && $(:) EOF BEGIN echo OK END However, because the value of checkkwd is either zeroed when it shouldn't, or isn't zeroed when it should, dash currently gets it wrong in every case. This patch fixes it by saving checkkwd and zeroing it where needed. function old new delta readtoken 157 176 +19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index f1c2118..5a001b0 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13265,10 +13265,14 @@ readtoken(void)
if (kwd & CHKNL) {
while (t == TNL) {
parseheredoc();
+ checkkwd = 0;
t = xxreadtoken();
}
}
+ kwd |= checkkwd;
+ checkkwd = 0;
+
if (t != TWORD || quoteflag) {
goto out;
}
@@ -13287,7 +13291,7 @@ readtoken(void)
}
}
- if (checkkwd & CHKALIAS) {
+ if (kwd & CHKALIAS) {
#if ENABLE_ASH_ALIAS
struct alias *ap;
ap = lookupalias(wordtext, 1);
@@ -13300,7 +13304,6 @@ readtoken(void)
#endif
}
out:
- checkkwd = 0;
#if DEBUG
if (!alreadyseen)
TRACE(("token '%s' %s\n", tokname_array[t], t == TWORD ? wordtext : ""));