shell: unify commands execution

This change removes special handling for shell root commands.
Currently there is one loop in execute function that is used
to search commands on each level.

Fixed a bug where command buffer has been processed twice
when it was not needed (wildcards not found).

This change will allow to simplify "select" command
introduction.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
Jakub Rzeszutko 2019-02-08 14:51:21 +01:00 committed by Anas Nashif
commit 2f040d8188
3 changed files with 26 additions and 41 deletions

View file

@ -225,7 +225,7 @@ static inline u32_t shell_root_cmd_count(void)
}
/* Function returning pointer to root command matching requested syntax. */
const struct shell_cmd_entry *shell_root_cmd_find(const char *syntax)
const struct shell_static_entry *shell_root_cmd_find(const char *syntax)
{
const size_t cmd_count = shell_root_cmd_count();
const struct shell_cmd_entry *cmd;
@ -233,7 +233,7 @@ const struct shell_cmd_entry *shell_root_cmd_find(const char *syntax)
for (size_t cmd_idx = 0; cmd_idx < cmd_count; ++cmd_idx) {
cmd = shell_root_cmd_get(cmd_idx);
if (strcmp(syntax, cmd->u.entry->syntax) == 0) {
return cmd;
return cmd->u.entry;
}
}