summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-07-01 23:50:15 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2006-07-01 23:50:15 +0000
commit7b49a25b5036f4224c989cf0084aa095c5d798ef (patch)
treeea05c7866164f8493bac6a3972b2a665eb61a477 /src
parent0830b1b82aa96651e7194211a8992f976f8c2683 (diff)
downloadcoreutils-7b49a25b5036f4224c989cf0084aa095c5d798ef.tar.xz
(main): With no operand, 'tail -f' now silently ignores the '-f'
only if standard input is a FIFO or pipe and POSIXLY_CORRECT is set.
Diffstat (limited to 'src')
-rw-r--r--src/tail.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/tail.c b/src/tail.c
index 1718a7729..767e0e75b 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -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;
}
}