diff --git a/parse.y.orig b/parse.y index f415d2e..76974f0 100644 --- a/parse.y.orig +++ b/parse.y @@ -1000,11 +1000,11 @@ coproc: COPROC shell_command ; if_command: IF compound_list THEN compound_list FI - { $$ = make_if_command ($2, $4, (COMMAND *)NULL); } + { $$ = make_if_command ($2, $4, (COMMAND *)NULL); if (word_top > 0) word_top--; } | IF compound_list THEN compound_list ELSE compound_list FI - { $$ = make_if_command ($2, $4, $6); } + { $$ = make_if_command ($2, $4, $6); if (word_top > 0) word_top--; } | IF compound_list THEN compound_list elif_clause FI - { $$ = make_if_command ($2, $4, $5); } + { $$ = make_if_command ($2, $4, $5); if (word_top > 0) word_top--; } ; @@ -5142,6 +5142,7 @@ got_token: case CASE: case SELECT: case FOR: + case IF: if (word_top < MAX_CASE_NEST) word_top++; word_lineno[word_top] = line_number; @@ -6020,9 +6021,13 @@ report_syntax_error (message) print_offending_line (); } else - { - msg = EOF_Reached ? _("syntax error: unexpected end of file") : _("syntax error"); - parser_error (line_number, "%s", msg); + { + if (EOF_Reached && word_top>=0) { + parser_error(line_number, _("syntax error: unexpected end of file from line %d."), word_lineno[word_top] ); + } else { + msg = EOF_Reached ? _("syntax error: unexpected end of file") : _("syntax error"); + parser_error (line_number, "%s", msg); + } /* When the shell is interactive, this file uses EOF_Reached only for error reporting. Other mechanisms are used to decide whether or not to exit. */