diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2018-03-09 23:07:53 +0800 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-03-28 21:42:54 +0000 |
commit | 54da8ae3f40ab0181d9cf5e915c2a01b62205888 (patch) | |
tree | 88788c5435061f95235b767dd9bd4a8e4480659f | |
parent | ef6ed3c138aaf680ff3e4e0d7fbad6d2c61fb7d0 (diff) | |
download | klibc-54da8ae3f40ab0181d9cf5e915c2a01b62205888.tar.gz |
[klibc] dash: parser: Fix single-quoted patterns in here-documents
[ dash commit 9ee3343965950bad08e97f43c8c376b89a50b099 ]
The script
x=*
cat <<- EOF
${x#'*'}
EOF
prints * instead of nothing as it should. The problem is that
when we're in sqsyntax context in a here-document, we won't add
CTLESC as we should. This patch fixes it:
Reported-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/dash/parser.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/usr/dash/parser.c b/usr/dash/parser.c index c28363caede75..cd980941d8d3f 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -934,7 +934,8 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs) USTPUTC(c, out); break; case CCTL: - if (eofmark == NULL || synstack->dblquote) + if ((!eofmark) | synstack->dblquote | + synstack->varnest) USTPUTC(CTLESC, out); USTPUTC(c, out); break; |