From a1df6a86bb85c79e7a4bae1e6770185c2ff8d2d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Mon, 10 Mar 2014 13:48:00 +0100 Subject: [PATCH] shell: don't ignore IO errors --- sys/shell/shell.c | 3 +++ tests/test_shell/main.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/shell/shell.c b/sys/shell/shell.c index ed53c081f3..5529348b8b 100644 --- a/sys/shell/shell.c +++ b/sys/shell/shell.c @@ -217,6 +217,9 @@ static int readline(shell_t *shell, char *buf, size_t size) } c = shell->readchar(); + if (c < 0) { + return 1; + } shell->put_char(c); /* We allow Unix linebreaks (\n), DOS linebreaks (\r\n), and Mac linebreaks (\r). */ diff --git a/tests/test_shell/main.c b/tests/test_shell/main.c index 58245e70ee..171418dc26 100644 --- a/tests/test_shell/main.c +++ b/tests/test_shell/main.c @@ -53,7 +53,10 @@ static void print_echo(int argc, char **argv) static int shell_readc(void) { char c; - posix_read(uart0_handler_pid, &c, 1); + int result = posix_read(uart0_handler_pid, &c, 1); + if (result != 1) { + return -1; + } return (unsigned char) c; }