GNU bug report logs - #8214
red hat lynx 'sort' bug?

Previous Next

Package: coreutils;

Reported by: "Niergarth, Jeffrey" <jniergar <at> ciena.com>

Date: Wed, 9 Mar 2011 21:05:02 UTC

Severity: normal

Tags: moreinfo, notabug, unreproducible

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: Bob Proulx <bob <at> proulx.com>
To: "Niergarth, Jeffrey" <jniergar <at> ciena.com>
Cc: 8214 <at> debbugs.gnu.org
Subject: bug#8214: red hat lynx 'sort' bug?
Date: Wed, 9 Mar 2011 14:40:19 -0700
tags 8214 + unreproducible moreinfo notabug
thanks

Niergarth, Jeffrey wrote:
> The 'sort' utility (no options) doesn't behave as expected:

Thank you for your bug report.  However this doesn't read like a bug
in sort but a misunderstanding of how locales affect it.

> Here are the pertinent results:
> 
> /fpga/OAF/HD/rtl/vhdl_wrapper/clock_monitor_synthesis.v
> /fpga/OAF/HD/rtl/vhdl_wrapper/clockmonitor_synthesis.v
> /fpga/OAF/HD/rtl/vhdl_wrapper/clock_monitor_synthesis.v IN
> /fpga/OAF/HD/rtl/vhdl_wrapper/clockmonitor_synthesis.v IN

That is sorted in the en_US.UTF-8 locale.  In order to sort in ASCII
order you would want to set your locale to C.

The man page says:

       ***  WARNING  ***  The locale specified by the environment affects sort
       order.  Set LC_ALL=C to get the traditional sort order that uses native
       byte values.

The info documentation says:

     Unless otherwise specified, all comparisons use the character
  collating sequence specified by the `LC_COLLATE' locale.(1)

     (1) If you use a non-POSIX locale (e.g., by setting `LC_ALL' to
  `en_US'), then `sort' may produce output that is sorted differently
  than you're accustomed to.  In that case, set the `LC_ALL' environment
  variable to `C'.  Note that setting only `LC_COLLATE' has two problems.
  First, it is ineffective if `LC_ALL' is also set.  Second, it has
  undefined behavior if `LC_CTYPE' (or `LANG', if `LC_CTYPE' is unset) is
  set to an incompatible value.  For example, you get undefined behavior
  if `LC_CTYPE' is `ja_JP.PCK' but `LC_COLLATE' is `en_US.UTF-8'.

This topic comes up often over the years.

Please see this faq for more information:

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

Personally I set the following in my ~/.bashrc file.

  export LANG=en_US.UTF-8
  export LC_COLLATE=C

Bob




This bug report was last modified 14 years and 137 days ago.

Previous Next


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