Eric Blake wrote:

I'm not sure whether this is a bug in POSIX or in bash, but I noticed the following with bash-3.2.39.

$ bash -c 'foo=$(cat <<EOF
hi
EOF)
echo $foo'

I agree with your analysis.  The reworked command-substitution parsing in
bash-4.0 makes this a syntax error.


Finally, bash has a definite bug, with no POSIX ambiguities:

$ bash -c 'cat <<EOF
hi'

Here, bash treats end-of-input as the heredoc delimiter, and prints "hi", even though it should be complaining of a syntax error since the heredoc (and thus the script) is unterminated. pdksh behaves correctly and fails with a syntax error.

This is how sh has behaved since at least version 7.  The v7 and SVR4.2 sh
(and ksh93) behave as bash does here.  I'm coming down on the side of
historical behavior here.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    [EMAIL PROTECTED]    http://cnswww.cns.cwru.edu/~chet/


Reply via email to