Re: POSIX shell specification insight requested
Branden Robinson wrote:
> Is the following construction POSIXly correct?
>
> foo=$(cat <<EOF
> Foo bar baz quux.
> EOF)
>
> ash (and dash, which is derived from ash) choke on this, and seem to
> ignore everything on the same line as, but after, the here-document
> terminator word.
I always thought that the terminator word must be the only thing on the
line.
The folloing shows that (d)ash does not consider EOF) to be a terminator
word because of the appended ")".
foo=$(cat <<EOF
Foo bar baz quux.
EOF)
EOF
)
echo $foo
So just use:
EOF
)
which works everywhere (and yes, I know that doesn't quite answer you actual
questin :))
Cheers,
Mika
Reply to: