hush: fix wrong prompt problem on empty interactive commants
authorDenys Vlasenko <dvlasenk@redhat.com>
Fri, 7 Jan 2011 14:16:05 +0000 (15:16 +0100)
committerDenys Vlasenko <dvlasenk@redhat.com>
Fri, 7 Jan 2011 14:16:05 +0000 (15:16 +0100)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
shell/hush.c

index a771e9cd99d8b5b2f8d614a6f5ef048f955cc213..24b9e6efecfe16854d226da7e9905695a7448b68 100644 (file)
@@ -4140,7 +4140,16 @@ static struct pipe *parse_stream(char **pstring,
                                if (IS_NULL_CMD(ctx.command)
                                 && dest.length == 0 && !dest.has_quoted_part
                                ) {
-                                       continue;
+                                       /* This newline can be ignored. But...
+                                        * without the below check, interactive shell
+                                        * will ignore even lines with bare <newline>,
+                                        * and show the continuation prompt:
+                                        * ps1_prompt$ <enter>
+                                        * ps2> _   <=== wrong prompt, should be ps1
+                                        */
+                                       struct pipe *pi = ctx.list_head;
+                                       if (pi->num_cmds != 0)
+                                               continue;
                                }
                                /* Treat newline as a command separator. */
                                done_pipe(&ctx, PIPE_SEQ);