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.
This commit is contained in:
Pádraig Brady committed 2013-04-04 03:01:48 +01:00
1 parent f7867e73ca
commit 7abf99e190
2 files changed
+9

No files matched your search

+4
View File
@@ -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];