Code

sysdb: Do not add duplicate entries to the history.
authorSebastian Harl <sh@tokkee.org>
Fri, 10 Jan 2014 15:40:58 +0000 (16:40 +0100)
committerSebastian Harl <sh@tokkee.org>
Sun, 12 Jan 2014 18:16:12 +0000 (19:16 +0100)
src/tools/sysdb/input.c

index dcd12b033d76cbaa61836013617bccde9acb64e4..939a5146a9ef2369c39de5d7c7f217f62a2dcc96 100644 (file)
@@ -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 */