diff mbox series

[6/6] main: Print \n upon EOF (CTRL-D) when run interactively

Message ID 20180907083414.14673-7-andrew.shadura@collabora.co.uk (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series [1/6] exec: Don't execute binary files if execve() returned ENOEXEC. | expand

Commit Message

Andrej Shadura Sept. 7, 2018, 8:34 a.m. UTC
From: Gerrit Pape <pape@smarden.org>

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
---
 src/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/main.c b/src/main.c
index e8e4256..6d53e00 100644
--- a/src/main.c
+++ b/src/main.c
@@ -221,8 +221,15 @@  cmdloop(int top)
 			if (!top || numeof >= 50)
 				break;
 			if (!stoppedjobs()) {
-				if (!Iflag)
+				if (!Iflag) {
+					if (iflag) {
+						out2c('\n');
+#ifdef FLUSHERR
+						flushout(out2);
+#endif
+					}
 					break;
+				}
 				out2str("\nUse \"exit\" to leave shell.\n");
 			}
 			numeof++;