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: Richard Neill
Subject: Re: Bash error message for unterminated heredoc is unhelpful.
Date: Sun, 29 Jun 2008 04:02:50 +0100
User-agent: Thunderbird 2.0.0.12 (X11/20080306)

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?

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.

Also, bash should tell us *why* the end-of-file is unexpected...

Incidentally, bash is similarly unhelpful in the case of an 'if'
statement  which is missing its 'fi', or a case missing its esac.

If the script is a long one, there's no easy way to locate the offending
token, short of laboriously commenting out sections and doing the
"divide-and-conquer" method.


Regards,

Richard




reply via email to

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