From 19ef74095086f45d2554be505e34647b5e437cad Mon Sep 17 00:00:00 2001 From: Jakub Rzeszutko Date: Thu, 8 Oct 2020 13:54:39 +0200 Subject: [PATCH] shell: fix compilation error Fix a compilation error when shell help feature was not selected and but shell help command was compiled. Fixes: #29042 Signed-off-by: Jakub Rzeszutko --- subsys/shell/shell_cmds.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/subsys/shell/shell_cmds.c b/subsys/shell/shell_cmds.c index 9a7006f035f..e022fa78393 100644 --- a/subsys/shell/shell_cmds.c +++ b/subsys/shell/shell_cmds.c @@ -297,8 +297,18 @@ static int cmd_help(const struct shell *shell, size_t argc, char **argv) "Please refer to shell documentation for more details."); #endif - /* For NULL argument function will print all root commands */ - shell_help_subcmd_print(shell, NULL, "\nAvailable commands:\n"); + if (IS_ENABLED(CONFIG_SHELL_HELP)) { + /* For NULL argument function will print all root commands */ + shell_help_subcmd_print(shell, NULL, "\nAvailable commands:\n"); + } else { + const struct shell_static_entry *entry; + size_t idx = 0; + + shell_print(shell, "\nAvailable commands:"); + while ((entry = shell_cmd_get(NULL, idx++, NULL)) != NULL) { + shell_print(shell, " %s", entry->syntax); + } + } return 0; }