Code

sysdb: Fixed check for duplicate history entries.
authorSebastian Harl <sh@tokkee.org>
Thu, 11 Dec 2014 21:42:39 +0000 (22:42 +0100)
committerSebastian Harl <sh@tokkee.org>
Thu, 11 Dec 2014 21:42:39 +0000 (22:42 +0100)
current_history() returns the currently *selected* history entry. Rather, we
want the latest entry, that is, the one added last.

src/tools/sysdb/input.c

index 08f639f1ac104c9a8c0527321bc92ba89070e4db..a88b2266147de67a659cd383e802a0a61701f7ce 100644 (file)
@@ -280,18 +280,18 @@ sdb_input_exec_query(void)
 {
        char *query = sdb_command_exec(sysdb_input);
 
-       HIST_ENTRY *current_hist;
-       const char *hist_line = NULL;
+       HIST_ENTRY *hist;
+       const char *prev = NULL;
 
        if (! query)
                return -1;
 
-       current_hist = current_history();
-       if (current_hist)
-               hist_line = current_hist->line;
+       hist = history_get(history_length);
+       if (hist)
+               prev = hist->line;
 
        if (*query != ' ')
-               if ((! hist_line) || strcmp(hist_line, query))
+               if ((! prev) || strcmp(prev, query))
                        add_history(query);
        free(query);
        return 0;