From: Sebastian Harl Date: Fri, 10 Jan 2014 15:40:58 +0000 (+0100) Subject: sysdb: Do not add duplicate entries to the history. X-Git-Tag: sysdb-0.1.0~237 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=457ae8f2d7e7a7473fb393ab797256f0cae9e05c;p=sysdb.git sysdb: Do not add duplicate entries to the history. --- 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 */