From 9ee3343965950bad08e97f43c8c376b89a50b099 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 9 Mar 2018 23:07:53 +0800 Subject: 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 Signed-off-by: Herbert Xu --- src/parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/parser.c b/src/parser.c index c28363c..cd98094 100644 --- a/src/parser.c +++ b/src/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; -- cgit 1.4.1