diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-05-02 19:18:34 +0400 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-05-02 19:18:34 +0400 |
commit | b1cfc453760b3b3b81bb3217f68074a98c96084b (patch) | |
tree | 3567c42f4fd94570e3e68fa9b0557fa93f098a7d | |
parent | aa0a12d5495a9cc8612e026ea5787eee4b019095 (diff) |
hush: fix handling of unterminated subshell: (<eof>. Fixes bug 229.
function old new delta
syntax_error_unexpected_ch 31 41 +10
parse_stream 2184 2191 +7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/shell/hush.c b/shell/hush.c index 5daca960c..255caef01 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -780,12 +780,12 @@ static void syntax_error_unterm_str(unsigned lineno, const char *s) die_if_script(lineno, "syntax error: unterminated %s", s); } -static void syntax_error_unexpected_ch(unsigned lineno, char ch) +static void syntax_error_unexpected_ch(unsigned lineno, int ch) { char msg[2]; msg[0] = ch; msg[1] = '\0'; - die_if_script(lineno, "syntax error: unexpected %s", msg); + die_if_script(lineno, "syntax error: unexpected %s", ch == EOF ? "EOF" : msg); } #if HUSH_DEBUG < 2 @@ -5448,10 +5448,17 @@ static struct pipe *parse_stream(char **pstring, if (heredoc_cnt) { syntax_error_unterm_str("here document"); - xfunc_die(); + goto parse_error; + } + /* end_trigger == '}' case errors out earlier, + * checking only ')' */ + if (end_trigger == ')') { + syntax_error_unterm_ch('('); /* exits */ + /* goto parse_error; */ } + if (done_word(&dest, &ctx)) { - xfunc_die(); + goto parse_error; } o_free(&dest); done_pipe(&ctx, PIPE_SEQ); |