summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-04-26 20:54:47 -0400
committerJakob Kaivo <jkk@ung.org>2022-04-26 20:54:47 -0400
commit59c73efe2c924d4e142f5411fd40c41910d2116c (patch)
tree02afd97ba62136bec5e9a6900f993c611b7464bc
parent6ec488aea8b0177b8f665eb6d84a732e9abad97c (diff)
actually read from stderr if possible, always end with a newline
-rw-r--r--more.c5
1 files changed, 3 insertions, 2 deletions
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");
}