From 5c81574ed52d294a58617c9bb8b86fb0caa1f71e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 8 Sep 2006 17:19:51 +0000 Subject: [PATCH] tail now ignores the -f option if POSIXLY_CORRECT is set, no file operand is given, and standard input is any FIFO. --- ChangeLog | 7 +++++++ NEWS | 4 ++++ doc/ChangeLog | 5 +++++ doc/coreutils.texi | 2 +- src/tail.c | 11 ++++++++--- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66bfa4dde..73283c6c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-09-08 Paul Eggert + + * NEWS: tail now ignores the -f option if POSIXLY_CORRECT is set, + no file operand is given, and standard input is any FIFO. + This is in response to Open Group XCU ERN 114. + * src/tail.c (main): Likewise. + 2006-09-08 Jim Meyering mv and "cp -r" no longer fail when invoked with two arguments diff --git a/NEWS b/NEWS index ffe7fcb05..73cdea3e9 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,10 @@ GNU coreutils NEWS -*- outline -*- now fails without removing anything. Likewise for any file name with a final `./' or `../' component. + tail now ignores the -f option if POSIXLY_CORRECT is set, no file + operand is given, and standard input is any FIFO; formerly it did + this only for pipes. + ** Infrastructure changes Coreutils now uses gnulib via the gnulib-tool script. diff --git a/doc/ChangeLog b/doc/ChangeLog index 3f863b08b..f2d23be3b 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2006-09-08 Paul Eggert + + * coreutils.texi (tail invocation): Ignore -f when standard input + is a FIFO, too. + 2006-09-02 Paul Eggert * coreutils.texi (Treating / specially): --preserve-root is diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 08de387fe..51493874c 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -2578,7 +2578,7 @@ with the long form of the option, not with @option{-f}. @vindex POSIXLY_CORRECT If @env{POSIXLY_CORRECT} is set, the @option{-f} option is ignored if -no @var{file} operand is specified and standard input is a pipe. +no @var{file} operand is specified and standard input is a FIFO or a pipe. @item -F @opindex -F diff --git a/src/tail.c b/src/tail.c index 082ddfc52..7d8f421e6 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1640,10 +1640,15 @@ main (int argc, char **argv) if (forever && getenv ("POSIXLY_CORRECT")) { - int is_a_pipe = isapipe (STDIN_FILENO); - if (is_a_pipe < 0) + struct stat st; + int is_a_fifo_or_pipe = + (fstat (STDIN_FILENO, &st) != 0 ? -1 + : S_ISFIFO (st.st_mode) ? 1 + : HAVE_FIFO_PIPES == 1 ? 0 + : isapipe (STDIN_FILENO)); + if (is_a_fifo_or_pipe < 0) error (EXIT_FAILURE, errno, _("standard input")); - if (is_a_pipe) + if (is_a_fifo_or_pipe) forever = false; } }