[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash-5.1-beta available

From: Chet Ramey
Subject: Re: Bash-5.1-beta available
Date: Mon, 14 Sep 2020 12:04:02 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0

On 9/13/20 4:51 PM, Robert Elz wrote:

>   | The specific construct is
>   |
>   | P=A
>   | cat <<EOF
>   | ${P+\"$P\"}
>   | EOF
> That should output \"A\"

OK, let's discuss it.

>   | In this case, the usual proscription on double quotes in here-documents
>   | does not apply, since the double quote appears within ${}.
> Huh?   Where does that come from, at best a " inside a quoted ${} is
> unspecified.   But in a here doc, " is simply not a quoting char at all.

"However, the double-quote character ( '"' ) [edited, since the HTML on the
web site is malformed] shall not be treated specially within a here-
document, except when the double-quote appears within "$()", "``", or


That implies that the double quote *is* treated specially when it appears
within a ${} expansion inside the body of a here-document, so the backslash
quotes it. The question is how special [insert eye-roll emoji], and what
rules you follow. It seems like shells follow the double-quoting rules if
they follow any.

(There's also whether or not the double quotes in the above text are
grammatical or syntactically significant.)

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]