On Thu, Mar 08, 2018 at 07:35:53PM +0100, Harald van Dijk wrote:
>
> Related:
>
> x=*; cat <<EOF
> ${x#'*'}
> EOF
>
> This shouldn't print anything either: because the * is quoted, it should be
> taken as a literal and removed from $x.
>
> Re-testing, I see this didn't work properly with my patch either.
I don't think this is related to our patches at all. It's an
independent bug. The fix isn't too hard.
---8<---
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 <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
diff --git a/src/parser.c b/src/parser.c
index 3aeb9f6..d86d71e 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -940,7 +940,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;
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html