parser: Fix alias expansion after heredoc or newlines
commit07951cfffb218291e7574b874660eab652cb54f1
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 28 Apr 2020 14:19:59 +0000 (29 00:19 +1000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 15 May 2020 06:24:38 +0000 (15 16:24 +1000)
treeba85a61937b42600400e9fb7a78e0181ce627fb9
parent50fc8edbe2532b573f2edb727861e3649b9dafef
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.

Suggested-by: Harald van Dijk <harald@gigawatt.nl>
Reported-by: Harald van Dijk <harald@gigawatt.nl>
Reported-by: Martijn Dekker <martijn@inlv.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
src/parser.c