shell: fix showing 'command not found'

After recent changes to shell, there is no more "no_such_command:
command not found" message when executing non-existing command. Restore
that message, so users are warned once again about wrong command,
instead of silently ignoring their request.

Fixes: 512de5ecac ("shell: Refactor command execution to enable raw
  arguments")
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This commit is contained in:
Marcin Niestroj 2020-05-23 18:42:57 +02:00 committed by Carles Cufí
parent 76d8f8f1e2
commit 62b985409e
1 changed files with 8 additions and 0 deletions

View File

@ -687,6 +687,14 @@ static int execute(const struct shell *shell)
&cmd_with_handler_lvl, &args_left);
parent = entry;
} else {
if (cmd_lvl == 0 &&
(!shell_in_select_mode(shell) ||
shell->ctx->selected_cmd->handler == NULL)) {
shell_internal_fprintf(shell, SHELL_ERROR,
"%s%s\n", argv[0],
SHELL_MSG_CMD_NOT_FOUND);
}
/* last handler found - no need to search commands in
* the next iteration.
*/