From f6aa2c72360ea298c1150766c1994190a3e00e1d Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Wed, 1 Aug 2018 03:56:39 +0200 Subject: [PATCH] client: Fix comparing current prompt against previous We'd add the new command propmpt to history if it was different from what current_history() returned which may not be the last command executed, so we'd possibly add multiple identical commands to history and skip some that were new. Instead compare against history_get(last index). Also remove an always-true part of the condition on the next line. --- client/display.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/client/display.c b/client/display.c index 1f37b6d6..4a1d6a97 100644 --- a/client/display.c +++ b/client/display.c @@ -446,10 +446,8 @@ static void readline_callback(char *prompt) if (!strlen(prompt)) goto done; - previous_prompt = current_history(); - if (!previous_prompt || - (previous_prompt && - strcmp(previous_prompt->line, prompt))) { + previous_prompt = history_get(history_base + history_length - 1); + if (!previous_prompt || strcmp(previous_prompt->line, prompt)) { add_history(prompt); }