]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(tac_file): When determining whether a file is seekable,
authorJim Meyering <jim@meyering.net>
Mon, 24 Oct 2005 16:07:36 +0000 (16:07 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 24 Oct 2005 16:07:36 +0000 (16:07 +0000)
also test whether it is a tty.  Using only the lseek-based test would
give a false positive on Solaris.  Reported by Peter Fales.

src/tac.c

index c5fbe24e6aebc2efde6077d2a34ff9e49edea8c1..0b68a0ef3d8b31804bb6500450a544b7a5d4781d 100644 (file)
--- a/src/tac.c
+++ b/src/tac.c
@@ -547,9 +547,9 @@ tac_file (const char *filename)
 
   file_size = lseek (fd, (off_t) 0, SEEK_END);
 
-  ok = (0 <= file_size
-       ? tac_seekable (fd, filename)
-       : tac_nonseekable (fd, filename));
+  ok = (file_size < 0 || isatty (fd)
+       ? tac_nonseekable (fd, filename)
+       : tac_seekable (fd, filename));
 
   if (!is_stdin && close (fd) != 0)
     {