diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-16 20:29:35 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-16 20:29:35 +0200 |
commit | b24e55da84093dd6bf6dff79627e32459c3da071 (patch) | |
tree | ce5f991b536aaac74a8f9cde431e0336eab4fced | |
parent | c49638b7d29e1010bfa95acbd013bf3268810bae (diff) | |
download | busybox-w32-b24e55da84093dd6bf6dff79627e32459c3da071.tar.gz busybox-w32-b24e55da84093dd6bf6dff79627e32459c3da071.tar.bz2 busybox-w32-b24e55da84093dd6bf6dff79627e32459c3da071.zip |
hush: fix "cmd1 && cmd2 &" handling on NOMMU
function old new delta
done_pipe 234 238 +4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/shell/hush.c b/shell/hush.c index 2a734f3de..8d9292ed1 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -3378,18 +3378,15 @@ static void done_pipe(struct parse_context *ctx, pipe_style type) | |||
3378 | ctx->ctx_inverted = 0; | 3378 | ctx->ctx_inverted = 0; |
3379 | ctx->pipe->res_word = ctx->ctx_res_w; | 3379 | ctx->pipe->res_word = ctx->ctx_res_w; |
3380 | #endif | 3380 | #endif |
3381 | if (type != PIPE_BG || ctx->list_head == ctx->pipe) { | 3381 | if (type == PIPE_BG && ctx->list_head != ctx->pipe) { |
3382 | no_conv: | 3382 | /* Necessary since && and || have precedence over &: |
3383 | ctx->pipe->followup = type; | ||
3384 | } else { | ||
3385 | /* Necessary since && and || have more precedence than &: | ||
3386 | * "cmd1 && cmd2 &" must spawn both cmds, not only cmd2, | 3383 | * "cmd1 && cmd2 &" must spawn both cmds, not only cmd2, |
3387 | * in a backgrounded subshell. | 3384 | * in a backgrounded subshell. |
3388 | */ | 3385 | */ |
3389 | struct pipe *pi; | 3386 | struct pipe *pi; |
3390 | struct command *command; | 3387 | struct command *command; |
3391 | 3388 | ||
3392 | /* Is this actually the case? */ | 3389 | /* Is this actually this construct, all pipes end with && or ||? */ |
3393 | pi = ctx->list_head; | 3390 | pi = ctx->list_head; |
3394 | while (pi != ctx->pipe) { | 3391 | while (pi != ctx->pipe) { |
3395 | if (pi->followup != PIPE_AND && pi->followup != PIPE_OR) | 3392 | if (pi->followup != PIPE_AND && pi->followup != PIPE_OR) |
@@ -3408,11 +3405,16 @@ static void done_pipe(struct parse_context *ctx, pipe_style type) | |||
3408 | command->cmd_type = CMD_NORMAL; | 3405 | command->cmd_type = CMD_NORMAL; |
3409 | command->group = ctx->list_head; | 3406 | command->group = ctx->list_head; |
3410 | #if !BB_MMU | 3407 | #if !BB_MMU |
3411 | //TODO: is this correct?! | 3408 | command->group_as_string = xstrndup( |
3412 | command->group_as_string = xstrdup(ctx->as_string.data); | 3409 | ctx->as_string.data, |
3410 | ctx->as_string.length - 1 /* do not copy last char, "&" */ | ||
3411 | ); | ||
3413 | #endif | 3412 | #endif |
3414 | /* Replace all pipes in ctx with one newly created */ | 3413 | /* Replace all pipes in ctx with one newly created */ |
3415 | ctx->list_head = ctx->pipe = pi; | 3414 | ctx->list_head = ctx->pipe = pi; |
3415 | } else { | ||
3416 | no_conv: | ||
3417 | ctx->pipe->followup = type; | ||
3416 | } | 3418 | } |
3417 | 3419 | ||
3418 | /* Without this check, even just <enter> on command line generates | 3420 | /* Without this check, even just <enter> on command line generates |
@@ -4855,7 +4857,9 @@ static struct pipe *parse_stream(char **pstring, | |||
4855 | * Really, ask yourself, why | 4857 | * Really, ask yourself, why |
4856 | * "cmd && <newline>" doesn't start | 4858 | * "cmd && <newline>" doesn't start |
4857 | * cmd but waits for more input? | 4859 | * cmd but waits for more input? |
4858 | * No reason...) | 4860 | * The only reason is that it might be |
4861 | * a "cmd1 && <nl> cmd2 &" construct, | ||
4862 | * cmd1 may need to run in BG). | ||
4859 | */ | 4863 | */ |
4860 | struct pipe *pi = ctx.list_head; | 4864 | struct pipe *pi = ctx.list_head; |
4861 | if (pi->num_cmds != 0 /* check #1 */ | 4865 | if (pi->num_cmds != 0 /* check #1 */ |