shell: fix execute command when help not active

When help functionality is not compiled and command is called with
-h or --help option shell will now either pass this option as
an argument or it will print a message that command does not have
a handler.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
Jakub Rzeszutko 2018-12-13 15:14:18 +01:00 committed by Carles Cufí
commit 956b00388f

View file

@ -527,7 +527,7 @@ static int exec_cmd(const struct shell *shell, size_t argc, char **argv,
int ret_val = 0;
if (shell->ctx->active_cmd.handler == NULL) {
if (help_entry.help) {
if ((help_entry.help) && IS_ENABLED(CONFIG_SHELL_HELP)) {
if (help_entry.help != shell->ctx->active_cmd.help) {
shell->ctx->active_cmd = help_entry;
}
@ -636,8 +636,9 @@ static int execute(const struct shell *shell)
break;
}
if (!strcmp(argv[cmd_lvl], "-h") ||
!strcmp(argv[cmd_lvl], "--help")) {
if (IS_ENABLED(CONFIG_SHELL_HELP) &&
(!strcmp(argv[cmd_lvl], "-h") ||
!strcmp(argv[cmd_lvl], "--help"))) {
/* Command called with help option so it makes no sense
* to search deeper commands.
*/