[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Non-expanding here-documents inside command substitution are subject
Re: Non-expanding here-documents inside command substitution are subject to newline joining
Sat, 11 Feb 2017 17:19:01 -0500
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.7.1
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'
> def \
> 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
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.
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/