bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: heredoc in command subst bug?


From: Chet Ramey
Subject: Re: heredoc in command subst bug?
Date: Fri, 13 Jun 2008 13:27:39 -0400
User-agent: Thunderbird 2.0.0.14 (Macintosh/20080421)

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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]