| 1 | #!/bin/bash |
| 2 | # here-commsub.sh |
| 3 | # Requires Bash version -ge 4.1 ... |
| 4 | |
| 5 | multi_line_var=$( cat <<ENDxxx |
| 6 | ------------------------------ |
| 7 | This is line 1 of the variable |
| 8 | This is line 2 of the variable |
| 9 | This is line 3 of the variable |
| 10 | ------------------------------ |
| 11 | ENDxxx) |
| 12 | |
| 13 | # Rather than what Bash 4.0 requires: |
| 14 | #+ that the terminating limit string and |
| 15 | #+ the terminating close-parenthesis be on separate lines. |
| 16 | |
| 17 | # ENDxxx |
| 18 | # ) |
| 19 | |
| 20 | |
| 21 | echo "$multi_line_var" |
| 22 | |
| 23 | # Bash still emits a warning, though. |
| 24 | # warning: here-document at line 10 delimited |
| 25 | #+ by end-of-file (wanted `ENDxxx') |