GNU bug report logs -
#9346
wc does not conform to POSIX (additional spaces)
Previous Next
Full log
Message #13 received at 9346 <at> debbugs.gnu.org (full text, mbox):
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.