ash: main: Print \n upon EOF (CTRL-D) when run interactively
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 16 Feb 2020 17:57:53 +0000 (18:57 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 16 Feb 2020 18:16:52 +0000 (19:16 +0100)
Upstream comment:

    Date: Fri, 7 Sep 2018 10:34:14 +0200
    main: Print \n upon EOF (CTRL-D) when run interactively

    Exiting dash via a ^D instead of with "exit" causes dash to forget to
    print a newline.

        sh-3.1$ sh
        sh-3.1$ ^D
        sh-3.1$ dash
        $ sh-3.1$

    It is more neat and tidy to send a newline similarly to what bash does,
    so it doesn't make the next prompt of the parent shell look ugly.

    Suggested by jidanni.

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    [reworded the patch description]
Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
    Bug-Debian: http://bugs.debian.org/476422
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c

index 138f19abdaeb7681c1aa8449f56208d4d9bab486..3958db123b6c5e8eece2aab4fe326895d25b74d8 100644 (file)
@@ -13302,8 +13302,12 @@ cmdloop(int top)
                        if (!top || numeof >= 50)
                                break;
                        if (!stoppedjobs()) {
-                               if (!Iflag)
+                               if (!Iflag) {
+                                       if (iflag) {
+                                               newline_and_flush(stderr);
+                                       }
                                        break;
+                               }
                                out2str("\nUse \"exit\" to leave shell.\n");
                        }
                        numeof++;