From 457ae8f2d7e7a7473fb393ab797256f0cae9e05c Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Fri, 10 Jan 2014 16:40:58 +0100 Subject: [PATCH] sysdb: Do not add duplicate entries to the history. --- src/tools/sysdb/input.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tools/sysdb/input.c b/src/tools/sysdb/input.c index dcd12b0..939a514 100644 --- a/src/tools/sysdb/input.c +++ b/src/tools/sysdb/input.c @@ -118,11 +118,19 @@ sdb_input_exec_query(sdb_input_t *input) { char *query = sdb_command_exec(input); + HIST_ENTRY *current_hist; + const char *hist_line = NULL; + if (! query) return -1; + current_hist = current_history(); + if (current_hist) + hist_line = current_hist->line; + if (*query != ' ') - add_history(query); + if ((! hist_line) || strcmp(hist_line, query)) + add_history(query); free(query); return 0; } /* sdb_input_exec_query */ -- 2.30.2