shell: add functionality to exit

This commit is contained in:
S.J.R. van Schaik 2017-06-14 13:20:28 +02:00
parent d709c44fa4
commit a5e783b6bb

View file

@ -4,13 +4,25 @@
#include <shell.h>
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);