index 08f639f1ac104c9a8c0527321bc92ba89070e4db..898464af0b550118aa0367337a4e4b85460930c6 100644 (file)
--- a/src/tools/sysdb/input.c
+++ b/src/tools/sysdb/input.c
return;
}
- if (sdb_client_eof(sysdb_input->client))
- sdb_input_reconnect();
-
sdb_strbuf_append(sysdb_input->input, "%s\n", line);
free(line);
return (ssize_t)(sdb_strbuf_len(sysdb_input->input) - len);
}
- if (sysdb_input->query_len)
+ if (sysdb_input->have_input)
prompt = "sysdb-> ";
if (sdb_client_eof(sysdb_input->client))
prompt = "!-> ";
int
sdb_input_exec_query(void)
{
- char *query = sdb_command_exec(sysdb_input);
+ char *query = NULL;
- HIST_ENTRY *current_hist;
- const char *hist_line = NULL;
+ HIST_ENTRY *hist;
+ const char *prev = NULL;
+
+ if (! sysdb_input->have_input) {
+ /* empty line */
+ if (sdb_client_eof(sysdb_input->client))
+ sdb_input_reconnect();
+ return 0;
+ }
+ query = sdb_command_exec(sysdb_input);
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;