From c4c2012284c3a3a45843e9400379c84855d853ef Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Apr 2018 13:29:20 +0200 Subject: ash: parser: Fix single-quoted patterns in here-documents Upstream commit: From: Herbert Xu Date: Fri, 9 Mar 2018 23:07:53 +0800 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 Signed-off-by: Denys Vlasenko --- shell/ash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shell/ash.c') diff --git a/shell/ash.c b/shell/ash.c index 97379cd92..70a278f42 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12005,7 +12005,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) } } #endif - if (eofmark == NULL || synstack->dblquote) + if (!eofmark || synstack->dblquote || synstack->varnest) USTPUTC(CTLESC, out); USTPUTC(c, out); break; -- cgit v1.2.3