diff --git a/shell/hush.c b/shell/hush.c index 62b1d48b4..c542b7dd9 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -5476,22 +5476,24 @@ static struct pipe *parse_stream(char **pstring, * will still trigger for us */ } } + + /* "cmd}" or "cmd }..." without semicolon or &: + * } is an ordinary char in this case, even inside { cmd; } + * Pathological example: { ""}; } should exec "}" cmd + */ + if (ch == '}' + && !(IS_NULL_PIPE(ctx.pipe) + && IS_NULL_CMD(ctx.command) + && dest.length == 0 + && !dest.o_quoted + ) + ) { + goto ordinary_char; + } + if (end_trigger && end_trigger == ch && (heredoc_cnt == 0 || end_trigger != ';') ) { - /* "{ cmd}" or "{ cmd }..." without semicolon or &: - * } is an ordinary char in this case. - * Pathological example: { ""}; } should exec "}" cmd - */ - if (ch == '}' - && !(IS_NULL_PIPE(ctx.pipe) - && IS_NULL_CMD(ctx.command) - && dest.length == 0 - && !dest.o_quoted - ) - ) { - goto ordinary_char; - } if (heredoc_cnt) { /* This is technically valid: * { cat <