Skip to content

Commit b94f142

Browse files
author
Michał Narajowski
committed
sys/shell: Fix command parameters completion
When trying to complete parameters for a command for which there are other commands with the same prefix, get_command_from_module function would return the first command with matching prefix instead of the first command that matches exactly. For the following example, when trying to list available params for command 'set' the shell would print out parameters for command 'set-scan-opts'. ``` set-scan-opts set set-adv-data set-scan-rsp set-priv-mode ``` This patch fixes this issue by ensuring that the found command matches exactly with the typed one.
1 parent 3ca145c commit b94f142

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sys/shell/src/shell.c

+5
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ get_command_from_module(const char *command, int len, int module)
470470

471471
shell_module = &shell_modules[module];
472472
for (i = 0; shell_module->commands[i].sc_cmd; i++) {
473+
474+
if (strlen(shell_module->commands[i].sc_cmd) != len) {
475+
continue;
476+
}
477+
473478
if (!strncmp(command, shell_module->commands[i].sc_cmd, len)) {
474479
return i;
475480
}

0 commit comments

Comments
 (0)