From 62b985409e88b32b3f93f784421e90617261fe4e Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Sat, 23 May 2020 18:42:57 +0200 Subject: [PATCH] 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: 512de5ecac62 ("shell: Refactor command execution to enable raw arguments") Signed-off-by: Marcin Niestroj --- subsys/shell/shell.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index 5ddf6fe5caa..5d76ec55926 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -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. */