From 0ee51c9dab0e04aeb578e18291983665f8a85f1f Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Thu, 20 Apr 2017 13:42:20 -0700 Subject: [PATCH] client: readline callback --- client/display.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/client/display.c b/client/display.c index 4604e1ae..1ff3c4bb 100644 --- a/client/display.c +++ b/client/display.c @@ -192,6 +192,29 @@ void display_command(const struct command_family *family, const char *cmd_name) static void readline_callback(char *prompt) { + HIST_ENTRY *previous_prompt; + + if (!prompt) { + display_quit(); + + l_main_quit(); + + return; + } + + if (!strlen(prompt)) + goto done; + + previous_prompt = current_history(); + if (!previous_prompt || + (previous_prompt && + strcmp(previous_prompt->line, prompt))) { + add_history(prompt); + } + + command_process_prompt(prompt); + +done: l_free(prompt); }