From 7b49a25b5036f4224c989cf0084aa095c5d798ef Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 1 Jul 2006 23:50:15 +0000 Subject: (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. --- src/tail.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') 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; } } -- cgit v1.2.3-54-g00ecf