diff --git a/lib/sl/sl.c b/lib/sl/sl.c index 940fbeb32..145346bba 100644 --- a/lib/sl/sl.c +++ b/lib/sl/sl.c @@ -135,6 +135,7 @@ sl_loop (SL_cmd *cmds, char *prompt) { unsigned max_count; char **ptr; + int ret; max_count = 17; ptr = malloc(max_count * sizeof(*ptr)); @@ -149,6 +150,7 @@ sl_loop (SL_cmd *cmds, char *prompt) unsigned count; SL_cmd *c; + ret = 0; buf = readline(prompt); if(buf == NULL) break; @@ -178,9 +180,13 @@ sl_loop (SL_cmd *cmds, char *prompt) } if (count > 0) { c = sl_match (cmds, ptr[0], 0); - if (c) - (*c->func)(count, ptr); - else + if (c) { + ret = (*c->func)(count, ptr); + if (ret != 0) { + free (buf); + break; + } + } else printf ("Unrecognized command: %s\n", ptr[0]); } free(buf); diff --git a/lib/sl/sl.h b/lib/sl/sl.h index fb785cb4a..7a8c01af0 100644 --- a/lib/sl/sl.h +++ b/lib/sl/sl.h @@ -41,7 +41,7 @@ #ifndef _SL_H #define _SL_H -typedef void (*cmd_func)(int, char **); +typedef int (*cmd_func)(int, char **); struct sl_cmd { char *name;