diff --git a/src/bin/util.c b/src/bin/util.c index 3b212655..0e739b1e 100644 --- a/src/bin/util.c +++ b/src/bin/util.c @@ -14,7 +14,7 @@ static char rawgetch(void) { struct termios saved, c; - char key; + int key; if (tcgetattr(fileno(stdin), &saved) < 0) return -1; @@ -33,7 +33,10 @@ static char rawgetch(void) key = getchar(); tcsetattr(fileno(stdin), TCSANOW, &saved); - return key; + if (key == EOF) + return -1; + + return (char)key; } int yorn(const char *fmt, ...)