On 2/11/17 12:11 AM, Michael Homer wrote: > If the same command is put inside command substitution instead, Bash (and > pdksh) behaves differently than the others, and performs newline joining to > have a single line in the middle “def ghi”. Given > x=$(cat <<'EOT' > abc > def \ > ghi > jkl > EOT > ) > In Bash, x now contains: > abc\ndef ghi\njkl
Thanks for the report. This is a bug in bash's command substitution parsing. > POSIX isn’t perfectly unambiguous here, but my intuition reading it is > consistent with everyone else’s behaviour rather than Bash’s. The relevant > parts of the specification I could find and more detail are given in > <http://unix.stackexchange.com/q/340923/73093>, and the original motivating > example was from someone trying to produce ASCII art inside command > substitution in an earlier question > <http://unix.stackexchange.com/q/340718/73093>. It is not necessarily ambiguous, but it does require close reading. > Geir Hauge in the comments of the question provided this patch to parse.y > purporting to solve the issue: <http://sprunge.us/ZMAT>. That's a good fix. 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://cnswww.cns.cwru.edu/~chet/