On Wed, Apr 04, 2018 at 06:27:45PM +0200, Denys Vlasenko wrote:
>
> This does not match what happens with this simple heredoc:
> 
> cat <<EOF
> \"
> EOF
> 
> # dash zz
> \"

Right, the special double quote part only comes into play inside
backquotes.  The reason is that the parsing of backquotes is done
in two parts.  We first have to detect the end of the backquote
expansion.  While doing so we will remove any backslashes that
are deemed to be special.

Once we have the complete string it is then fed into the parser
again.  During this stage the backslash is already gone so the
double quote becomes an actual double quote rather than a literal
one.

This is how it works in ksh93 too.

If you want to have guarantee a literal backslash inside a here-
document then you should always do \\.

Cheers,
-- 
Email: Herbert Xu <herb...@gondor.apana.org.au>
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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to