From 4eda0ed782faecdf600312cea7484e271d8008ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 13 Jun 2018 12:10:00 +0200 Subject: [PATCH] posix main shell: fix getchar() return value and check for EOF to avoid busy loop --- platforms/posix/src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platforms/posix/src/main.cpp b/platforms/posix/src/main.cpp index 790d8f4947..35f563d1b5 100644 --- a/platforms/posix/src/main.cpp +++ b/platforms/posix/src/main.cpp @@ -533,11 +533,15 @@ int main(int argc, char **argv) while (!_ExitFlag) { - char c = getchar(); + int c = getchar(); string add_string; // string to add at current cursor position bool update_prompt = true; switch (c) { + case EOF: + _ExitFlag = true; + break; + case 127: // backslash if (mystr.length() - cursor_position > 0) { mystr.erase(mystr.length() - cursor_position - 1, 1);