From 295ee521bc1a4f473ee8b7b5a4be32c5b5c7386f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 5 Jun 2012 12:24:49 +0200 Subject: head: with --lines=-N (-n-N) reset file pointer on seekable input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/head.c (elide_tail_lines_seekable): Reset file pointer after printing up to an end-relative line-counted offset. Anoop Sharma reported the problem and suggested the fix. * tests/misc/head-pos: Add coverage via a very similar, existing test. Also add coverage for a previously untested block of code. * tests/misc/head-elide-tail ($READ_BUFSIZE): Update to 8192, to match the value of BUFSIZ I see today on Fedora 17/x86_64 (unrelated to this fix). * NEWS (Bug fixes): Mention it. Improved-by: Pádraig Brady --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 7c7c2c30e..c0e5fdbbb 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,13 @@ GNU coreutils NEWS -*- outline -*- processes will not intersperse their output. [the bug dates back to the initial implementation] + head --lines=-N (-n-N) now resets the read pointer of a seekable input file. + This means that "head -n-3" no longer consumes all of its input, and lines + not output by head may be processed by other programs. For example, this + command now prints the final line, 2, while before it would print nothing: + seq 2 > k; (head -n-1 > /dev/null; cat) < k + [This bug was present in "the beginning".] + ls --color would mis-color relative-named symlinks in / [bug introduced in coreutils-8.17] -- cgit v1.2.3-70-g09d2