From 98c46d10ee81f206f274da312086a3f0533582af Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 18 Jan 2011 17:30:07 +0100 Subject: [PATCH] hush: fix "cmd & " problem Signed-off-by: Denys Vlasenko --- shell/hush.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 6970c50c4..3581ba119 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -4141,15 +4141,26 @@ static struct pipe *parse_stream(char **pstring, && dest.length == 0 && !dest.has_quoted_part ) { /* This newline can be ignored. But... - * without the below check, interactive shell - * will ignore even lines with bare , - * and show the continuation prompt: + * Without check #1, interactive shell + * ignores even bare , + * and shows the continuation prompt: * ps1_prompt$ - * ps2> _ <=== wrong prompt, should be ps1 + * ps2> _ <=== wrong, should be ps1 + * Without check #2, "cmd & " + * is similarly mistreated. + * (BTW, this makes "cmd & cmd" + * and "cmd && cmd" non-orthogonal. + * Really, ask yourself, why + * "cmd && " doesn't start + * cmd but waits for more input? + * No reason...) */ struct pipe *pi = ctx.list_head; - if (pi->num_cmds != 0) + if (pi->num_cmds != 0 /* check #1 */ + && pi->followup != PIPE_BG /* check #2 */ + ) { continue; + } } /* Treat newline as a command separator. */ done_pipe(&ctx, PIPE_SEQ); -- 2.25.1