bug-bash
[Top][All Lists]
Advanced

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

Re: Bash error message for unterminated heredoc is unhelpful.


From: Chet Ramey
Subject: Re: Bash error message for unterminated heredoc is unhelpful.
Date: Wed, 02 Jul 2008 09:27:00 -0400
User-agent: Thunderbird 2.0.0.14 (Macintosh/20080421)

Richard Neill wrote:
Chet Ramey wrote:
Richard Neill wrote:
Dear All,

In some cases, bash gives exceptionally unhelpful error messages, of the
sort "Unexpected end of file". This is next-to-useless as a debugging
aid, since there is no way to find out where the error really lies.
For better or worse, bash allows end-of-file to delimit a here document.
That is historical sh behavior.

The end-of-file syntax error message comes when the shell tries to read
the token following the here document.

Chet



Thanks for your reply.

Fair point. But nevertheless, couldn't bash still tell us why the EOF is
unexpected, and where the _start_ of the offending syntax lies?

It does.

The here document reads to EOF, which delimits the document.  The next
token read is EOF again, which causes the syntax error.  The start of
the offending syntax is the last line of the file.

I added a warning when here documents are delimited by EOF, but bash will
continue to accept that as valid for backwards compatibility.

That was the point of my second example: the error is still an
unexpected EOF, but in that case, bash also informs the user that the
missing ')' is due to a '(' which was on line 5.

Because that construct may not be delimited by EOF.

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

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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