GNU bug report logs - #18893
Bug with Gnu sort program in coreutils 8.4

Previous Next

Package: coreutils;

Reported by: Michael Yang <pstester2015 <at> gmail.com>

Date: Wed, 29 Oct 2014 22:22:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eric Blake <eblake <at> redhat.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#18893: closed (Bug with Gnu sort program in coreutils 8.4)
Date: Wed, 29 Oct 2014 22:37:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 29 Oct 2014 16:36:23 -0600
with message-id <54516BE7.2060905 <at> redhat.com>
and subject line Re: bug#18893: Bug with Gnu sort program in coreutils 8.4
has caused the debbugs.gnu.org bug report #18893,
regarding Bug with Gnu sort program in coreutils 8.4
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
18893: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18893
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Michael Yang <pstester2015 <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Bug with Gnu sort program in coreutils 8.4
Date: Wed, 29 Oct 2014 17:58:23 -0400
[Message part 3 (text/plain, inline)]
Hi,



There might be a bug in the “sort” program in GNU coreutils 8.4, present at
least in CentOS 6 x86_64.  It’s not immediately obvious to me whether or
not this bug has been reported before.



Given the following:



CC = gcc

CC = aCC

CCFLAGS =

CC = cc



sort (GNU coreutils) 8.4 yields:



CC = aCC

CC = cc

CCFLAGS =

CC = gcc



… the 3rd line is out-of-order.  In comparison, sort (GNU coreutils) 8.14
in cygwin yields:



CC = aCC

CC = cc

CC = gcc

CCFLAGS =



… which is correct.
[Message part 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
From: Eric Blake <eblake <at> redhat.com>
To: Michael Yang <pstester2015 <at> gmail.com>, 18893-done <at> debbugs.gnu.org
Subject: Re: bug#18893: Bug with Gnu sort program in coreutils 8.4
Date: Wed, 29 Oct 2014 16:36:23 -0600
[Message part 6 (text/plain, inline)]
tag 18893 notabug
thanks

On 10/29/2014 03:58 PM, Michael Yang wrote:

> There might be a bug in the “sort” program in GNU coreutils 8.4, present at
> least in CentOS 6 x86_64.  It’s not immediately obvious to me whether or
> not this bug has been reported before.

Thanks for the report.  However, it has been frequently reported, to the
point that it has a FAQ entry:

https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#Sort-does-not-sort-in-normal-order_0021

> sort (GNU coreutils) 8.4 yields:
> 
> 
> 
> CC = aCC
> 
> CC = cc
> 
> CCFLAGS =
> 
> CC = gcc

You can use the --debug flag to see what is going on (well, you can when
using new enough sort; 8.4 is rather old these days, and while there
HAVE been sort bug fixes in the meantime, they are for rather obscure
corner cases and not for your issue).

$ printf 'CC = aCC\nCC = cc\nCCFLAGS =\nCC = gcc\n' | sort --debug
sort: using ‘en_US.UTF-8’ sorting rules
CC = aCC
________
CC = cc
_______
CCFLAGS =
_________
CC = gcc
________

I'm guessing that on your CentOS box, your locale is set to en_US.UTF-8,
or some similar locale which collates case-insensitively and ignores
punctuation.  In such a collation sequence, you are comparing 'ccflags'
vs. 'ccgcc', and the final output order is correct.

> … the 3rd line is out-of-order.  In comparison, sort (GNU coreutils) 8.14
> in cygwin yields:

The version of sort makes no difference; rather, it is entirely up to
the locale (and by the way, cygwin now ships with 8.23, so you may want
to upgrade); on your cygwin box, I'm guessing that you are using the C
locale.  And even if you are using the en_US locale there, you must
remember that the cygwin locale definitions come from Windows, not
glibc, and therefore may differ in what the two locale writers thought
would make sense (that is, while the glibc en_US locale ignores
punctuation, maybe the Windows en_US locale does not).  At any rate, on
your CentOS box, you can force the C locale to get the same behavior as
cygwin seemed to give by default:

$ printf 'CC = aCC\nCC = cc\nCCFLAGS =\nCC = gcc\n' | LC_ALL=C sort --debug
sort: using simple byte comparison
CC = aCC
________
CC = cc
_______
CC = gcc
________
CCFLAGS =
_________

Therefore, I'm closing this as not a bug, but feel free to respond if
you have further comments or questions.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 10 years and 211 days ago.

Previous Next


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