hush: fix "cmd & <newline>" problem

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-01-18 17:30:07 +01:00
parent b9f2d9f7d9
commit 98c46d10ee

View File

@ -4141,15 +4141,26 @@ static struct pipe *parse_stream(char **pstring,
&& dest.length == 0 && !dest.has_quoted_part && dest.length == 0 && !dest.has_quoted_part
) { ) {
/* This newline can be ignored. But... /* This newline can be ignored. But...
* without the below check, interactive shell * Without check #1, interactive shell
* will ignore even lines with bare <newline>, * ignores even bare <newline>,
* and show the continuation prompt: * and shows the continuation prompt:
* ps1_prompt$ <enter> * ps1_prompt$ <enter>
* ps2> _ <=== wrong prompt, should be ps1 * ps2> _ <=== wrong, should be ps1
* Without check #2, "cmd & <newline>"
* is similarly mistreated.
* (BTW, this makes "cmd & cmd"
* and "cmd && cmd" non-orthogonal.
* Really, ask yourself, why
* "cmd && <newline>" doesn't start
* cmd but waits for more input?
* No reason...)
*/ */
struct pipe *pi = ctx.list_head; 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; continue;
}
} }
/* Treat newline as a command separator. */ /* Treat newline as a command separator. */
done_pipe(&ctx, PIPE_SEQ); done_pipe(&ctx, PIPE_SEQ);