1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-03-01 10:33:30 +02:00

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
2013-03-26 00:36:01 +00:00
parent f7867e73ca
commit 7abf99e190
2 changed files with 9 additions and 0 deletions

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];

View File

@@ -29,6 +29,11 @@ require_proc_pid_status_
touch empty || framework_failure_
echo anything > nonempty || framework_failure_
# First verify that -[nc]0 without -f, exit without reading
touch unreadable || framework_failure_
chmod 0 unreadable || framework_failure_
tail -c0 unreadable || fail=1
tail -n0 unreadable || fail=1
for inotify in ---disable-inotify ''; do
for file in empty nonempty; do