From 59c73efe2c924d4e142f5411fd40c41910d2116c Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 26 Apr 2022 20:54:47 -0400 Subject: actually read from stderr if possible, always end with a newline --- more.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'more.c') diff --git a/more.c b/more.c index 14a4c2e..abc9101 100644 --- a/more.c +++ b/more.c @@ -777,6 +777,7 @@ static int more_cat(const char *path, void (*loop)(FILE *)) static void more_exit(void) { tcsetattr(fileno(more_in), TCSANOW, &more_term); + printf("\n"); } int main(int argc, char *argv[]) @@ -837,8 +838,8 @@ int main(int argc, char *argv[]) return ret; } - more_in = stderr; - if (1 || read(fileno(more_in), NULL, 0) == -1) { + more_in = fdopen(STDERR_FILENO, "r"); + if (more_in == NULL) { more_in = fopen("/dev/tty", "r"); } -- cgit v1.2.1