mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 01:31:55 +00:00
History deduplication in birdc.
This commit is contained in:
parent
e14bd38087
commit
064e7be5cd
@ -135,6 +135,14 @@ submit_server_command(char *cmd)
|
|||||||
num_lines = 2;
|
num_lines = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_history_dedup(char *cmd)
|
||||||
|
{
|
||||||
|
/* Add history line if it differs from the last one */
|
||||||
|
HIST_ENTRY *he = history_get(history_length);
|
||||||
|
if (!he || strcmp(he->line, cmd))
|
||||||
|
add_history(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
got_line(char *cmd_buffer)
|
got_line(char *cmd_buffer)
|
||||||
@ -151,7 +159,7 @@ got_line(char *cmd_buffer)
|
|||||||
cmd = cmd_expand(cmd_buffer);
|
cmd = cmd_expand(cmd_buffer);
|
||||||
if (cmd)
|
if (cmd)
|
||||||
{
|
{
|
||||||
add_history(cmd);
|
add_history_dedup(cmd);
|
||||||
|
|
||||||
if (!handle_internal_command(cmd))
|
if (!handle_internal_command(cmd))
|
||||||
submit_server_command(cmd);
|
submit_server_command(cmd);
|
||||||
@ -159,7 +167,7 @@ got_line(char *cmd_buffer)
|
|||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
add_history(cmd_buffer);
|
add_history_dedup(cmd_buffer);
|
||||||
}
|
}
|
||||||
free(cmd_buffer);
|
free(cmd_buffer);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user