3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 21:22:37 +01:00

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.
This commit is contained in:
Andrew Zaborowski 2018-08-01 03:56:39 +02:00 committed by Denis Kenzior
parent f00c228665
commit f6aa2c7236

View File

@ -446,10 +446,8 @@ static void readline_callback(char *prompt)
if (!strlen(prompt)) if (!strlen(prompt))
goto done; goto done;
previous_prompt = current_history(); previous_prompt = history_get(history_base + history_length - 1);
if (!previous_prompt || if (!previous_prompt || strcmp(previous_prompt->line, prompt)) {
(previous_prompt &&
strcmp(previous_prompt->line, prompt))) {
add_history(prompt); add_history(prompt);
} }