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