posix main shell: fix getchar() return value and check for EOF to avoid busy loop

This commit is contained in:
Beat Küng 2018-06-13 12:10:00 +02:00 committed by Lorenz Meier
parent 226d7c79da
commit 4eda0ed782

View File

@ -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);