bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: uniq -c outputs SPACES NUMBER TAB LINE


From: Eric Blake
Subject: Re: uniq -c outputs SPACES NUMBER TAB LINE
Date: Wed, 25 Feb 2009 21:18:34 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Leif LeBaron <this <at> bb9.org> writes:

Hello Leif,

> 
> > Why do you think it's a bug?
> 
> I imagine the insertion of leading spaces was deliberate, but I refer to it 
as bug because it has already been
> registered as such in your bug tracker, and also for the following reasons.
> 
> - It appears to be undocumented (I checked both, man and info pages).

Would you care to submit a documentation patch?

> 
> - It appears to violate susv3
> (<http://www.opengroup.org/onlinepubs/009695399/utilities/uniq.html>) which 
clearly states:

That link is outdated (from POSIX 2001); the latest text (from POSIX 2008) is 
here:

http://www.opengroup.org/onlinepubs/9699919799/utilities/uniq.html

But the text you quoted is still the same across the two releases:

> 
>       If the -c option is specified, the output file shall be empty or each 
line shall be of the form:
>       "%d %s", <number of duplicates>, <line>

The thing you are missing, however, are these additional lines from POSIX 
(again, I'm quoting POSIX 2008, but identical wording was in POSIX 2001):

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

| ' ' 
| (An empty character position.) Represents one or more <blank> characters.
...
| If both the field width and precision are omitted, the implementation may
| precede, follow, or precede and follow numeric arguments of types d , i , and
| u with <blank> characters

And since both <tab> and <space> fall in the category of <blank>, and the %d 
specifies neither width nor precision, our existing output with leading spaces 
and a separating tab is 100% compliant.

> 
> - It breaks other commands, for example:
> 
>       This should work:
>       
>               cat textfile | sort | uniq -c | cut -d " " -f 2-

No, POSIX does not guarantee that it will work.

> > Please reply not to me directly, but rather to the
> > bug-coreutils <at> gnu.org mailing list.
> 
> By the way, I replied using the button on the website
> <http://lists.gnu.org/archive/html/bug-textutils/2003-07/msg00013.html> (so, 
you may want to
> change that address).

The bug-textutils list is old, from the days before it was consolidated to bug-
coreutils.  But the old alias still forwards to the new list.

-- 
Eric Blake







reply via email to

[Prev in Thread] Current Thread [Next in Thread]