Thanks for the report and all the references.
Here's the fix (relative to the latest test release).
Now I get this:
$ yes |./head -08|wc -l
8
$ yes |./head -010|wc -l
10
Index: head.c
===================================================================
RCS file: /fetish/textutils/src/head.c,v
retrieving revision 1.57
diff -u -p -r1.57 head.c
--- head.c 1999/04/24 12:33:25 1.57
+++ head.c 2000/05/12 20:20:02
@@ -223,7 +223,7 @@ string_to_integer (int count_lines, cons
strtol_error s_err;
uintmax_t n;
- s_err = xstrtoumax (n_string, NULL, 0, &n, "bkm");
+ s_err = xstrtoumax (n_string, NULL, 10, &n, "bkm");
if (s_err == LONGINT_INVALID)
{
"Joseph S. Myers" <[EMAIL PROTECTED]> writes:
| On Fri, 12 May 2000, J. Lasser wrote:
|
| > The command `cat /etc/passwd [ or anything else ] | head -7` works fine.
| > It works fine with head -8, head -9, and head -10.
| >
| > It works fine with head -01, -02, -03, -04, and so on. But head -08 and
| > head -09 produce errors of the following sort:
| >
| > [jon@dood home]$ head -08
| > head: 08: number of lines is so large that it is not representable
| > [jon@dood home]$
|
| This appears to be a bug in head; it should not interpret the number given
| as octal, and the message given for what in this case is an invalid octal
| number is misleading.
|
| POSIX.2 subclause 2.10.1(6) specifies that, unless otherwise specified,
| numeric operands and option-arguments are to be interpreted as decimal
| integers; the inclusion of 0 there would seem to imply that the C Standard
| definition of decimals should not be applied here. The definition of head
| (4.29.3) states that the numeric argument shall be a positive decimal
| integer. So I believe that head -010 should produce 10 (as on Solaris
| 2.6, for example) rather than 8 (as with GNU textutils 2.0) lines, in the
| absence of an official POSIX.2 interpretation saying otherwise. (However,
| arithmetic expressions in the shell should interpret values beginning with
| 0 as octal; there seems to be a recent interpretation, number 173,
| confirming this
| <URL:http://www.pasc.org/interps/unofficial/db/p1003.2/pasc-1003.2-173.html>.)