Skip to contentSkip to conversation

cli: print newline with ctrl-d with editline

PATCH New Pablo Neira Ayuso 1 participant 1 message Nov 25, 2021 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 cli: print newline with ctrl-d with editline

If user does not explicitly 'quit' then print a newline before going back to the shell.

---
 src/cli.c | 5 +++++
 1 file changed, 5 insertions(+)
src/cli.c +5 -0
index 11fc85abeaa2..8762a636fd41 100644
@@ -38,6 +38,7 @@
 #define CMDLINE_QUIT		"quit"
 
 static char histfile[PATH_MAX];
+static bool quit;
 
 static void
 init_histfile(void)
@@ -140,6 +141,7 @@ static void cli_complete(char *line)
 		return;
 
 	if (!strcmp(line, CMDLINE_QUIT)) {
+		quit = true;
 		cli_exit();
 		exit(0);
 	}
@@ -221,6 +223,9 @@ void cli_exit(void)
 {
 	rl_deprep_terminal();
 	write_history(histfile);
+	/* Print \n when user exits via ^D */
+	if (!quit)
+		printf("\n");
 }
 
 #else /* HAVE_LINENOISE */
Signature · 1 line
2.30.2