[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug found in head

From: Bob Proulx
Subject: Re: bug found in head
Date: Thu, 13 Feb 2003 00:00:24 -0700
User-agent: Mutt/1.3.28i

Nik Reiman wrote:
> I think I found a bug in the GNU head, from textutils version 2.0.

Thanks for the report.  I don't have an answer.  But I will contribute
some information on the problem.  If you follow up, please reply to
the list.

> For some reason, head has trouble parsing numbers with a leading 0;
> and primarily the numbers "08" and "09".  For instance:
> $ for x in `seq -f '%02g' 1 10` ; \

The %02 format is generating numbers with a leading zero.  Example: 08
and 09.  That leading zero is causing the number to be interpreted as
an octal number.

> head: 08: number of lines is so large that it is not representable
> head: 09: number of lines is so large that it is not representable

Yes in the case that 08 and 09 are values larger than representable by
an octal number.  Only the digits 0-7 are allowed.

As to whether this is proper or not I cannot comment.  However, the
standards documentation seems to support decimal input only.


  -n number
    The first number lines of each input file will be copied to standard
    output. The number option-argument must be a positive decimal integer.

It would seem on my casual reading that the base must always be
decimal here.  But I don't know the history and there may be

Remove the leading zero and and try your example again and I am sure
it will function as you expect.  Just use '%2'.  Actually you don't
need any formatting.

  for x in `seq 1 10` ; \
  do cat /etc/passwd | head -n $x | tail -n 1 ; \

As an aside comment concerning this code, there is much overhead!
While I assume it is a contrived example I can't take it and must
comment upon it regardless.  You don't need the useless 'cat' process.
It is not doing anything for you.  Just redirect the input from the
file and remove the wasted data copy.  And using head and tail to
print a single line is moving a lot of data to no good effect.

  for x in `seq 1 10` ; do
    sed -n ${x}p < /etc/passwd

To recreate the issue with head just use head:

  head -n 08 < /dev/null
  head: 08: number of lines is so large that it is not representable

But don't let my comments about your script put you off.  I am just
persnickety about such things.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]