From 07915ac580a032d39e21359f87bebbccd7baff91 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 5 Nov 2018 16:03:21 +0100 Subject: [PATCH] Shell: skip empty lines --- os/services/shell/shell.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/os/services/shell/shell.c b/os/services/shell/shell.c index c219b1903..5347080a8 100644 --- a/os/services/shell/shell.c +++ b/os/services/shell/shell.c @@ -98,19 +98,22 @@ PT_THREAD(shell_input(struct pt *pt, shell_output_func output, const char *cmd)) cmd++; } - /* Look for arguments */ - args = strchr(cmd, ' '); - if(args != NULL) { - *args = '\0'; - args++; - } + /* Skip empty lines */ + if(*cmd != '\0') { + /* Look for arguments */ + args = strchr(cmd, ' '); + if(args != NULL) { + *args = '\0'; + args++; + } - cmd_descr = shell_command_lookup(cmd); - if(cmd_descr != NULL) { - static struct pt cmd_pt; - PT_SPAWN(pt, &cmd_pt, cmd_descr->func(&cmd_pt, output, args)); - } else { - SHELL_OUTPUT(output, "Command not found. Type 'help' for a list of commands\n"); + cmd_descr = shell_command_lookup(cmd); + if(cmd_descr != NULL) { + static struct pt cmd_pt; + PT_SPAWN(pt, &cmd_pt, cmd_descr->func(&cmd_pt, output, args)); + } else { + SHELL_OUTPUT(output, "Command not found. Type 'help' for a list of commands\n"); + } } output_prompt(output);