ash: parser: Fix single-quoted patterns in here-documents
Upstream commit: From: Herbert Xu <herbert@gondor.apana.org.au> 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 <harald@gigawatt.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
8b536eb40d
commit
c4c2012284
@ -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;
|
||||
|
4
shell/ash_test/ash-heredoc/heredoc_var_expand1.right
Normal file
4
shell/ash_test/ash-heredoc/heredoc_var_expand1.right
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
Ok1:0
|
||||
|
||||
Ok2:0
|
11
shell/ash_test/ash-heredoc/heredoc_var_expand1.tests
Executable file
11
shell/ash_test/ash-heredoc/heredoc_var_expand1.tests
Executable file
@ -0,0 +1,11 @@
|
||||
x='*'
|
||||
|
||||
cat <<- EOF
|
||||
${x#'*'}
|
||||
EOF
|
||||
echo Ok1:$?
|
||||
|
||||
cat <<EOF
|
||||
${x#'*'}
|
||||
EOF
|
||||
echo Ok2:$?
|
Loading…
Reference in New Issue
Block a user