bug-bash
[Top][All Lists]
Advanced

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

Re: ${p+\"$p\"}


From: Chet Ramey
Subject: Re: ${p+\"$p\"}
Date: Mon, 21 Jan 2019 16:04:30 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.3.3

On 1/21/19 11:38 AM, Robert Elz wrote:
>     Date:        Mon, 21 Jan 2019 09:37:02 -0500
>     From:        Chet Ramey <address@hidden>
>     Message-ID:  <address@hidden>
> 
>   | It's the here-document. Backslashes and double quotes in here documents 
> are
>   | kind of strange. This is historical sh behavior.
> 
> Not so much backslashes, a here doc (this form) is just a double
> quoted string, and \ behaves in it like in any other double quoted
> string - escaping the special chars, and otherwise simply being
> left alone.
> 
> What is odd is that even though it is a double quoted string, the
> double quote character is just a character, and has no quoting
> effects at all.  And as it is not special, the \" combination is
> simply the two characters \ and ".
> 
> This really gets ugly when var expansions (the old forms, not the
> new pattern matching ones, or any of the ones that are not posix
> which bash supports) which was being used in this case.   Quoting
> inside a double quoted string, inside a var expansion is bad enough
> on the command line, in a here doc it is just a disaster.
> 
> For what it is worth, both bosh and the FreeBSD shell
> produce
> 
> \"A\"
> "A"

There's little consistency. The SVR4.2 sh produces the above. Bash and dash
produce

\"A\"
A

ksh93, mksh, and yash produce

"A"
A


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



reply via email to

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