[Toybox] [PATCH v2 1/1] teach head -c

Rob Landley rob at landley.net
Mon Jun 26 12:27:28 PDT 2017


On 06/01/2017 01:36 AM, Ilya Kuzmich wrote:
> ping?

Let's see...

>> Not POSIX, but implemented in coreutils, busybox and freebsd.

1) Do you have a use case for this? Or did you implement this because
it's there? Denys added it to Busybox on February 25, 2013 but no
message titles in the busybox mailing list around then mention "head" (I
checked from February 2013 back to the previous November). I couldn't a
bug report in https://bugs.busybox.net/buglist.cgi?quicksearch=head
either. So it looks like when busybox was ~15 years old Denys added this
because he could, not because anybody requested it or particularly
noticed it was missing...

2) On ubuntu "echo hello | head -c 0" produces no output. This one looks
like it falls back to line based behavior?

3) The ubuntu version has a more complicated -c behavior than you
implemented, "head -c -6600 README" currently prints the first 24 bytes
of that file. Why did you stop there? Why do we need this part but not
all of it? (Our tail already implements the -c +k behavior, but somebody
had an existing use case that needed it...)

4) I am really uncomfortable pointing to posix _and_ a man page as a
spec. (The old saying "A person with one watch always knows the time, a
person with two is never sure."*) There are two other files that use man
pages as their spec, and it's because neither posix nor lsb specify
nsenter/unshare/partprobe. I'd rather just add it to a "deviations from
posix" section if it's a posix command...

*shrug* I admit this a more convenient syntax than doing it with dd
(which is the first thing that comes to mind for me), but could you
explain your reasoning for this patch a bit more? And/or any second
opinions out there?

Thanks,

Rob

*  A person with three or more is going to have an endlessly expanding
todo list, you can just tell. I say this having spent months wrestling
with https://www.navcen.uscg.gov/pubs/gps/sigspec/gpssps1.pdf which
requires _5_ nanosecond-accurate clocks to accurately tell you where you
are. 4 in the satellites, one in the receiver.



More information about the Toybox mailing list