[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9346: wc does not conform to POSIX (additional spaces)
From: |
Pádraig Brady |
Subject: |
bug#9346: wc does not conform to POSIX (additional spaces) |
Date: |
Tue, 23 Aug 2011 02:07:59 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110707 Thunderbird/5.0 |
tags 9346 + notabug
On 08/23/2011 01:39 AM, Vincent Lefevre wrote:
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/wc.html
> says:
>
> STDOUT
>
> By default, the standard output shall contain an entry for each
> input file of the form:
>
> "%d %d %d %s\n", <newlines>, <words>, <bytes>, <file>
>
> But wc from GNU coreutils 8.12 adds spaces:
>
> $ echo | wc
> 1 0 1
>
> Setting POSIXLY_CORRECT=1 doesn't even have any effect here.
>
POSIX refers to the printf format above as a pseudo-printf format,
to contrast with the format used in SYS V of "%7d%7d%7d %s\n".
Notice the lack of spaces there, hence problems with big numbers.
So I take the POSIX printf format you referenced, just to ensure
at least 1 space is guaranteed between counts.
Also for any kind of portability, one will need to deal with
a variable number of spaces.
GNU wc uses a dynamic width (try it on a small file),
while also ensuring at least 1 space is present.
cheers,
Pádraig.