diff options
author | Jim Meyering <meyering@redhat.com> | 2009-09-08 08:26:22 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-09-08 13:30:38 +0200 |
commit | f0ff8c73fe8ae505d2029e905b23ac534d11990c (patch) | |
tree | 5fc18422e8764f5431adfd72a484a4dd1088fb9f /src | |
parent | e8591fd39f70932d40e9a6ddd4e607a89a3162f2 (diff) | |
download | coreutils-f0ff8c73fe8ae505d2029e905b23ac534d11990c.tar.xz |
tail: make the new piped-stdin test as portable as the old one
* src/tail.c (main): Adapt piped-stdin test to use the same isapipe,
test as was used in the preceding POSIXLY_CORRECT condition.
Remove the now-subsumed POSIXLY_CORRECT test.
Reported by Pádraig Brady.
* doc/coreutils.texi (tail invocation): Document this change.
* NEWS (Changes in behavior): Reclassify, clarify.
Diffstat (limited to 'src')
-rw-r--r-- | src/tail.c | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/src/tail.c b/src/tail.c index 63874bb01..81cbae037 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1922,28 +1922,6 @@ main (int argc, char **argv) static char *dummy_stdin = (char *) "-"; n_files = 1; file = &dummy_stdin; - - /* POSIX says that -f is ignored if no file operand is specified - 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. */ - - if (forever && getenv ("POSIXLY_CORRECT")) - { - 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_fifo_or_pipe) - forever = false; - } } { @@ -1986,8 +1964,13 @@ main (int argc, char **argv) size_t n_viable = 0; for (i = 0; i < n_files; i++) { - if (STREQ (F[i].name, "-") && !F[i].ignore - && 0 <= F[i].fd && S_ISFIFO (F[i].mode)) + bool is_a_fifo_or_pipe = + (STREQ (F[i].name, "-") + && !F[i].ignore + && 0 <= F[i].fd + && (S_ISFIFO (F[i].mode) + || (HAVE_FIFO_PIPES != 1 && isapipe (F[i].fd)))); + if (is_a_fifo_or_pipe) F[i].ignore = true; else ++n_viable; |