shell: add functionality to exit

tags/0.1.0
S.J.R. van Schaik 7 years ago
parent d709c44fa4
commit a5e783b6bb
  1. 16
      source/shell/cmd.c

@ -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);

Loading…
Cancel
Save