]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(main): With no operand, 'tail -f' now silently ignores the '-f'
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 1 Jul 2006 23:50:15 +0000 (23:50 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 1 Jul 2006 23:50:15 +0000 (23:50 +0000)
only if standard input is a FIFO or pipe and POSIXLY_CORRECT is set.

src/tail.c

index 1718a77297c5053341d96f79cf4ffdc922fb46fa..767e0e75bd6b42bff058cc735263798f1d660336 100644 (file)
@@ -1635,12 +1635,19 @@ main (int argc, char **argv)
       file = &dummy_stdin;
 
       /* POSIX says that -f is ignored if no file operand is specified
-        and standard input is a pipe.  */
-      if (forever)
+        and standard input is a pipe.  However, the GNU coding
+        standards say that program behavior should not depend on
+        device type, because device independence is an important
+        principle of the system's design.
+
+        Follow the POSIX requirement only if POSIXLY_CORRECT is set.
+        Ideally this would ignore -f only for pipes, but S_ISFIFO
+        succeeds for both FIFOs and pipes and we know of no portable,
+        reliable way to distinguish them.  */
+      if (forever && getenv ("POSIXLY_CORRECT"))
        {
          struct stat stats;
-         if (fstat (STDIN_FILENO, &stats) == 0
-             && IS_PIPE_LIKE_FILE_TYPE (stats.st_mode))
+         if (fstat (STDIN_FILENO, &stats) == 0 && S_ISFIFO (stats.st_mode))
            forever = false;
        }
     }