On 1/21/19 11:38 AM, Robert Elz wrote: > Date: Mon, 21 Jan 2019 09:37:02 -0500 > From: Chet Ramey <chet.ra...@case.edu> > Message-ID: <de2a733a-0d8e-2181-ead6-2729664ac...@case.edu> > > | 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 c...@case.edu http://tiswww.cwru.edu/~chet/