GNU bug report logs - #33281
head does not consume input after '-c' is satisfied

Previous Next

Package: coreutils;

Reported by: Luiz Angelo Daros de Luca <luizluca <at> gmail.com>

Date: Mon, 5 Nov 2018 20:34:01 UTC

Severity: wishlist

Tags: wontfix

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Luiz Angelo Daros de Luca <luizluca <at> gmail.com>
To: 33281 <at> debbugs.gnu.org
Subject: bug#33281: head does not consume input after '-c' is satisfied
Date: Mon, 5 Nov 2018 18:30:17 -0200
[Message part 1 (text/plain, inline)]
Hello,

Once head read enough bytes to satisfy -c option, it stops reading input
and quit.
This is different from what -n does and it is also different from both
FreeBSD and busybox head implementation.

With GNU Coreutils head:

$ echo -e "123\n456\n789" | { head -n 1; while read a; do echo "-$a-";
done; }
123
$ echo -e "123\n456\n789" | { head -c 4; while read a; do echo "-$a-";
done; }
123
-456-
-789-
$

With all other head implementations I tested:

$ echo -e "123\n456\n789" | { head -c 4 ; while read a ; do echo "-$a-" ;
done ; }
123
$

It would make sense to both -n and -c have the same meaning, differing only
whether to read bytes or lines.

Regards,
-- 

Luiz Angelo Daros de Luca
luizluca <at> gmail.com
[Message part 2 (text/html, inline)]

This bug report was last modified 6 years and 235 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.