From adabd8c930fe9a321023f06c272b821ab1fefce0 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 29 Apr 2015 20:53:03 +0200 Subject: [PATCH] shell: let readline return an error on empty line so prompt gets print again --- sys/shell/shell.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/shell/shell.c b/sys/shell/shell.c index 77393eede9..9e2770291a 100644 --- a/sys/shell/shell.c +++ b/sys/shell/shell.c @@ -223,15 +223,12 @@ static int readline(shell_t *shell, char *buf, size_t size) /* QEMU transmits only a single '\r' == 13 on hitting enter ("-serial stdio"). */ /* DOS newlines are handled like hitting enter twice, but empty lines are ignored. */ if (c == '\r' || c == '\n') { - if (line_buf_ptr == buf) { - /* The line is empty. */ - continue; - } - *line_buf_ptr = '\0'; shell->put_char('\r'); shell->put_char('\n'); - return 0; + + /* return 1 if line is empty, 0 otherwise */ + return line_buf_ptr == buf; } /* QEMU uses 0x7f (DEL) as backspace, while 0x08 (BS) is for most terminals */ else if (c == 0x08 || c == 0x7f) { @@ -257,7 +254,11 @@ static inline void print_prompt(shell_t *shell) { shell->put_char('>'); shell->put_char(' '); + +#ifdef MODULE_NEWLIB fflush(stdout); +#endif + return; }