[klibc] [klibc:update-dash] dash: main: Print \n upon EOF (CTRL-D) when run interactively

klibc-bot for Gerrit Pape pape at smarden.org
Sat Mar 28 14:49:32 PDT 2020

Commit-ID:  d754d32592fa1c6359b37d101485ced1ff7cdf79
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=d754d32592fa1c6359b37d101485ced1ff7cdf79
Author:     Gerrit Pape <pape at smarden.org>
AuthorDate: Fri, 7 Sep 2018 10:34:14 +0200
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 28 Mar 2020 21:42:55 +0000

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

[ dash commit 413c6dcc3ca3891825ae8239251140882d7c6c6c ]

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 at smarden.org>
Signed-off-by: Jonathan Nieder <jrnieder at gmail.com>
[reworded the patch description]
Signed-off-by: Andrej Shadura <andrew.shadura at collabora.co.uk>
Bug-Debian: http://bugs.debian.org/476422
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

 usr/dash/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

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

More information about the klibc mailing list