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.

Full log


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




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

Previous Next


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