Re: [PATCH 1/2] test-lib: allow test snippets as here-docs
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
>> + # start with a newline, to match hanging newline from open-quote style
>> + eval "$1=\$LF"
>> + local test_line
>> + while IFS= read -r test_line
>> + do
>> + eval "$1=\${$1}\${test_line}\${LF}"
>> + done
>
> I wonder if we can do this without relying on "read -r" (which I
> distrust, perhaps out of superstition)? Perhaps by slurping the
> whole thing with "$(cat)"?Meaning, something along this line...
----- >8 --------- >8 --------- >8 --------- >8 ----
#!/bin/sh
LF='
'
ttt () {
eval "$1"='$LF$(cat)'
}
ttt script <<\EOT
a
b
EOT
echo "<<<$script>>>"
----- 8< --------- 8< --------- 8< --------- 8< ----