summaryrefslogtreecommitdiffstats
path: root/package/busybox/busybox-1.18.2/busybox-1.18.2-hush.patch
blob: d08e5194d6bfb80fdc8cbbc26089f6105c2a7cd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--- busybox-1.18.2/shell/hush.c
+++ busybox-1.18.2-hush/shell/hush.c
@@ -4123,15 +4123,26 @@ static struct pipe *parse_stream(char **
 				 && 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 <newline>,
-					 * and show the continuation prompt:
+					 * Without check #1, interactive shell
+					 * ignores even bare <newline>,
+					 * and shows the continuation prompt:
 					 * 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;
-					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);
OpenPOWER on IntegriCloud