shell: add functionality to exit
This commit is contained in:
parent
d709c44fa4
commit
a5e783b6bb
1 changed files with 15 additions and 1 deletions
|
@ -4,13 +4,25 @@
|
||||||
|
|
||||||
#include <shell.h>
|
#include <shell.h>
|
||||||
|
|
||||||
|
static int should_exit = 0;
|
||||||
|
static void do_exit(const char *s);
|
||||||
|
|
||||||
struct cmd main_cmds[] = {
|
struct cmd main_cmds[] = {
|
||||||
|
{ "exit", do_exit },
|
||||||
|
{ "quit", do_exit },
|
||||||
{ "flash", do_flash_cmd },
|
{ "flash", do_flash_cmd },
|
||||||
{ "ftl", do_ftl_cmd },
|
{ "ftl", do_ftl_cmd },
|
||||||
{ "mufs", do_mufs_cmd },
|
{ "mufs", do_mufs_cmd },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void do_exit(const char *s)
|
||||||
|
{
|
||||||
|
(void)s;
|
||||||
|
|
||||||
|
should_exit = 1;
|
||||||
|
}
|
||||||
|
|
||||||
static char *prompt(const char *prefix)
|
static char *prompt(const char *prefix)
|
||||||
{
|
{
|
||||||
char *alloc, *line;
|
char *alloc, *line;
|
||||||
|
@ -69,7 +81,9 @@ void cmd_loop(const char *show)
|
||||||
{
|
{
|
||||||
char *line;
|
char *line;
|
||||||
|
|
||||||
while (1) {
|
should_exit = 0;
|
||||||
|
|
||||||
|
while (!should_exit) {
|
||||||
line = prompt(show);
|
line = prompt(show);
|
||||||
cmd_exec(main_cmds, line);
|
cmd_exec(main_cmds, line);
|
||||||
free(line);
|
free(line);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue