[PATCH nft] cli: print newline with ctrl-d with editline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/cli.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/cli.c b/src/cli.c
index 11fc85abeaa2..8762a636fd41 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -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 */
-- 
2.30.2




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux