GNU bug report logs - #9346
wc does not conform to POSIX (additional spaces)

Previous Next

Package: coreutils;

Reported by: Vincent Lefevre <vincent <at> vinc17.net>

Date: Tue, 23 Aug 2011 00:42:01 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9346 in the body.
You can then email your comments to 9346 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9346; Package coreutils. (Tue, 23 Aug 2011 00:42:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent <at> vinc17.net>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Tue, 23 Aug 2011 00:42:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: bug-coreutils <at> gnu.org
Subject: wc does not conform to POSIX (additional spaces)
Date: Tue, 23 Aug 2011 02:39:09 +0200
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.

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)




Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Tue, 23 Aug 2011 01:11:01 GMT) Full text and rfc822 format available.

Notification sent to Vincent Lefevre <vincent <at> vinc17.net>:
bug acknowledged by developer. (Tue, 23 Aug 2011 01:11:02 GMT) Full text and rfc822 format available.

Message #10 received at 9346-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Vincent Lefevre <vincent <at> vinc17.net>, 9346-done <at> debbugs.gnu.org
Subject: Re: bug#9346: wc does not conform to POSIX (additional spaces)
Date: Tue, 23 Aug 2011 02:07:59 +0100
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.




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9346; Package coreutils. (Tue, 23 Aug 2011 01:51:02 GMT) Full text and rfc822 format available.

Message #13 received at 9346 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: 9346 <at> debbugs.gnu.org, P <at> draigBrady.com
Subject: Re: bug#9346: wc does not conform to POSIX (additional spaces)
Date: Mon, 22 Aug 2011 19:47:55 -0600
On 08/22/2011 07:07 PM, Pádraig Brady wrote:
> 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.

Correct, because it is not a POSIX violation.

>>
>
> 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".

The official wording is here:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap05.html#tag_05

   3. The following characters have the following special meaning in 
the format string:

''    (An empty character position.) Represents one or more <blank> 
characters.
∆    Represents exactly one <space> character.

Since the POSIX specification for wc uses space, and not the special 
delta symbol, it is intended to be arbitrary amount of blanks (space or 
tabs), according as the tool designers think fit, and you cannot 
portably rely on an exact number, but can rely on the fact that no 
matter how large the numbers are, the columns will not run into one another.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 20 Sep 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 333 days ago.

Previous Next


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