shell: Add 'exit' command to leave a module
In console shell, add explicit, 'exit' command to leave the current module. Currently this is being achieved by overloading select command (without an argument). Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
This commit is contained in:
parent
5963904e4c
commit
faaf859a46
1 changed files with 14 additions and 0 deletions
|
@ -242,6 +242,7 @@ static int show_help(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
print_module_commands(module);
|
print_module_commands(module);
|
||||||
|
printk("\nEnter 'exit' to leave current module.\n");
|
||||||
} else { /* help for all entities */
|
} else { /* help for all entities */
|
||||||
printk("Available modules:\n");
|
printk("Available modules:\n");
|
||||||
for (module = 0; module < NUM_OF_SHELL_ENTITIES; module++) {
|
for (module = 0; module < NUM_OF_SHELL_ENTITIES; module++) {
|
||||||
|
@ -289,6 +290,15 @@ static int select_module(int argc, char *argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int exit_module(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc == 1) {
|
||||||
|
default_module = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static shell_cmd_function_t get_cb(int argc, char *argv[])
|
static shell_cmd_function_t get_cb(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char *first_string = argv[0];
|
const char *first_string = argv[0];
|
||||||
|
@ -310,6 +320,10 @@ static shell_cmd_function_t get_cb(int argc, char *argv[])
|
||||||
return select_module;
|
return select_module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(first_string, "exit")) {
|
||||||
|
return exit_module;
|
||||||
|
}
|
||||||
|
|
||||||
if ((argc == 1) && (default_module == -1)) {
|
if ((argc == 1) && (default_module == -1)) {
|
||||||
printk("Missing parameter\n");
|
printk("Missing parameter\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue