diff --git a/source/shell/cmd.c b/source/shell/cmd.c index 65c66fd..ddc95f7 100644 --- a/source/shell/cmd.c +++ b/source/shell/cmd.c @@ -4,13 +4,25 @@ #include +static int should_exit = 0; +static void do_exit(const char *s); + struct cmd main_cmds[] = { + { "exit", do_exit }, + { "quit", do_exit }, { "flash", do_flash_cmd }, { "ftl", do_ftl_cmd }, { "mufs", do_mufs_cmd }, { NULL, NULL }, }; +static void do_exit(const char *s) +{ + (void)s; + + should_exit = 1; +} + static char *prompt(const char *prefix) { char *alloc, *line; @@ -69,7 +81,9 @@ void cmd_loop(const char *show) { char *line; - while (1) { + should_exit = 0; + + while (!should_exit) { line = prompt(show); cmd_exec(main_cmds, line); free(line);