[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: here-documents in $(command) substitution
From: |
Chet Ramey |
Subject: |
Re: here-documents in $(command) substitution |
Date: |
Mon, 28 Nov 2016 14:00:53 -0800 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 |
On 11/27/16 9:51 AM, Eduardo Bustamante wrote:
> Delimiter (in your case the three character string "EOF"), has to be
> on its own line, with no leading or trailing blanks (or any other
> characters). If bash 3.x used to behave different, it's because it was
> buggy.
Not exactly. Bash has always supported the Bourne shell extension of
allowing the command substitution terminator to delimit a here document.
> Hence, the proper way to do a here-document inside command substitution:
>
> hp% cat hd
> export foo=$(cat <<EOF
> echo bar
> EOF
> )
This is true and obeys the letter of the standard.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/