[Finsh] Stop push new history when current cmd is same as last cmd.
This commit is contained in:
parent
db88c0b6a2
commit
c123451585
|
@ -371,6 +371,9 @@ static void shell_push_history(struct finsh_shell *shell)
|
|||
{
|
||||
/* push history */
|
||||
if (shell->history_count >= FINSH_HISTORY_LINES)
|
||||
{
|
||||
/* if current cmd is same as last cmd, don't push */
|
||||
if (memcmp(&shell->cmd_history[FINSH_HISTORY_LINES - 1], shell->line, shell->line_position))
|
||||
{
|
||||
/* move history */
|
||||
int index;
|
||||
|
@ -385,8 +388,13 @@ static void shell_push_history(struct finsh_shell *shell)
|
|||
/* it's the maximum history */
|
||||
shell->history_count = FINSH_HISTORY_LINES;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if current cmd is same as last cmd, don't push */
|
||||
if (shell->history_count == 0 || memcmp(&shell->cmd_history[shell->history_count - 1], shell->line, shell->line_position))
|
||||
{
|
||||
shell->current_history = shell->history_count;
|
||||
memset(&shell->cmd_history[shell->history_count][0], 0, FINSH_CMD_SIZE);
|
||||
memcpy(&shell->cmd_history[shell->history_count][0], shell->line, shell->line_position);
|
||||
|
||||
|
@ -394,6 +402,7 @@ static void shell_push_history(struct finsh_shell *shell)
|
|||
shell->history_count ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
shell->current_history = shell->history_count;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue