From 7abf99e1907b1b05cb45eacaa98bfa73efe0ab92 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Tue, 26 Mar 2013 00:36:01 +0000 Subject: tail: exit without reading input if would never output * src/tail.c (main): If -n0 or -c0 were specified without -f, then no data would ever be output, so exit without reading input. * tests/tail-2/tail-n0f.sh: Augment the related test with this case. --- src/tail.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/tail.c b/src/tail.c index ca851ee6f..cdaecddc4 100644 --- a/src/tail.c +++ b/src/tail.c @@ -2149,6 +2149,10 @@ main (int argc, char **argv) " indefinitely is ineffective")); } + /* Don't read anything if we'll never output anything. */ + if (! n_units && ! forever && ! from_start) + exit (EXIT_SUCCESS); + F = xnmalloc (n_files, sizeof *F); for (i = 0; i < n_files; i++) F[i].name = file[i]; -- cgit v1.2.3-54-g00ecf