Skip to contentSkip to conversation

cli: save history on ctrl-d

PATCH Superseded Pablo Neira Ayuso 1 participant 1 message Nov 24, 2021 netfilter

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 cli: save history on ctrl-d

Missing call to cli_exit() to save the history when ctrl-d is pressed in nft -i.

Moreover, remove call to rl_callback_handler_remove() in cli_exit() for editline cli since it does not call rl_callback_handler_install().

---
 src/cli.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
src/cli.c +14 -7
index 8729176680cf..11fc85abeaa2 100644
@@ -152,13 +152,6 @@ static void cli_complete(char *line)
 	nft_run_cmd_from_buffer(cli_nft, line);
 	free(line);
 }
-
-void cli_exit(void)
-{
-	rl_callback_handler_remove();
-	rl_deprep_terminal();
-	write_history(histfile);
-}
 #endif
 
 #if defined(HAVE_LIBREADLINE)
@@ -188,6 +181,13 @@ int cli_init(struct nft_ctx *nft)
 	return 0;
 }
 
+void cli_exit(void)
+{
+	rl_callback_handler_remove();
+	rl_deprep_terminal();
+	write_history(histfile);
+}
+
 #elif defined(HAVE_LIBEDIT)
 
 int cli_init(struct nft_ctx *nft)
@@ -212,10 +212,17 @@ int cli_init(struct nft_ctx *nft)
 
 		cli_complete(line);
 	}
+	cli_exit();
 
 	return 0;
 }
 
+void cli_exit(void)
+{
+	rl_deprep_terminal();
+	write_history(histfile);
+}
+
 #else /* HAVE_LINENOISE */
 
 int cli_init(struct nft_ctx *nft)
Signature · 1 line
2.30.2