summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/hilex.c7
-rw-r--r--bin/man1/hilex.13
2 files changed, 6 insertions, 4 deletions
diff --git a/bin/hilex.c b/bin/hilex.c
index 93401d95..59c1f12d 100644
--- a/bin/hilex.c
+++ b/bin/hilex.c
@@ -121,10 +121,10 @@ enum Option {
 typedef void Header(const char *opts[]);
 typedef void Output(const char *opts[], enum Class class, const char *text);
 
-static bool tty;
+static bool pager;
 static void ansiHeader(const char *opts[]) {
 	(void)opts;
-	if (!(tty = isatty(STDOUT_FILENO))) return;
+	if (!pager) return;
 	const char *shell = getenv("SHELL");
 	const char *pager = getenv("PAGER");
 	if (!shell) shell = "/bin/sh";
@@ -152,7 +152,7 @@ static void ansiHeader(const char *opts[]) {
 
 static void ansiFooter(const char *opts[]) {
 	(void)opts;
-	if (!tty) return;
+	if (!pager) return;
 	int status;
 	fclose(stdout);
 	wait(&status);
@@ -365,6 +365,7 @@ int main(int argc, char *argv[]) {
 		path = argv[optind];
 		file = fopen(path, "r");
 		if (!file) err(EX_NOINPUT, "%s", path);
+		pager = isatty(STDOUT_FILENO);
 	}
 
 	if (!name) {
diff --git a/bin/man1/hilex.1 b/bin/man1/hilex.1
index e07695a3..ffa20bcf 100644
--- a/bin/man1/hilex.1
+++ b/bin/man1/hilex.1
@@ -65,7 +65,8 @@ input lexer if one cannot be inferred.
 .Bl -tag -width Ds
 .It Cm ansi
 Output ANSI terminal control sequences.
-If standard output is a terminal,
+If standard output is a terminal
+and standard input is not being read,
 output is piped to
 .Ev PAGER
 with