[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: |
Eric Blake |
Subject: |
bug#9346: wc does not conform to POSIX (additional spaces) |
Date: |
Mon, 22 Aug 2011 19:47:55 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.11 |
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 address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org