[Top][All Lists]

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

bug#8214: red hat lynx 'sort' bug?

From: Bob Proulx
Subject: bug#8214: red hat lynx 'sort' bug?
Date: Wed, 9 Mar 2011 14:40:19 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

tags 8214 + unreproducible moreinfo notabug

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:


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

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


reply via email to

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