klibc-bot for Herbert Xu
2019-Jan-25 03:15 UTC
[klibc] [klibc:update-dash] parser: Fix single-quoted patterns in here-documents
Commit-ID: 1b256320b2da39c93e8e891e4a0b473488b68a3a
Gitweb:
http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=1b256320b2da39c93e8e891e4a0b473488b68a3a
Author: Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Fri, 9 Mar 2018 23:07:53 +0800
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Fri, 25 Jan 2019 02:57:21 +0000
[klibc] parser: Fix single-quoted patterns in here-documents
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 at gigawatt.nl>
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
usr/dash/parser.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/usr/dash/parser.c b/usr/dash/parser.c
index c28363ca..cd980941 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;
Maybe Matching Threads
- [klibc:update-dash] parser: Add syntax stack for recursive parsing
- [klibc:update-dash] dash: parser: Add syntax stack for recursive parsing
- [klibc:update-dash] dash: parser: Fix single-quoted patterns in here-documents
- [klibc:update-dash] parser: use pgetc_eatbnl() in more places
- [klibc:update-dash] dash: parser: use pgetc_eatbnl() in more places
