lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 1d438432: Specify a more reasonable locale fo


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 1d438432: Specify a more reasonable locale for sorting
Date: Mon, 10 Apr 2023 11:59:09 -0400 (EDT)

branch: master
commit 1d4384324af7ed205006ac0e936d7011a0143558
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Specify a more reasonable locale for sorting
---
 gwc/.zshrc | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/gwc/.zshrc b/gwc/.zshrc
index 2d954995..a3e4bdf2 100644
--- a/gwc/.zshrc
+++ b/gwc/.zshrc
@@ -49,11 +49,23 @@ export coefficiency="--jobs=$(nproc)"
 # have a persistent nonempty value on one particular machine:
 unset LC_ALL
 
-# redhat-based distributions may lack 'C.UTF-8'--see:
+# The "en_US.UTF-8" locale sorts data unreasonably, so use a C locale
+# for sorting. Specify both LC_COLLATE and LC_CTYPE together to avoid
+# unpleasant surprises. Prefer the "C.UTF-8" locale for sorting, if
+# available; otherwise (e.g., for redhat-based distributions that may
+# lack 'C.UTF-8':
 #   https://bugzilla.redhat.com/show_bug.cgi?id=902094
-if locale -a | grep --quiet C.UTF-8; then
-  pref_lc=C.UTF-8; else
-  pref_lc=en_US.UTF-8;
+# ) fall back to the "C" locale.
+#
+# The 'locale -a' command may display something like "C.utf8",
+# rather than the desired "C.UTF-8"; therefore, instead of:
+#   if locale -a | grep --quiet C.UTF-8
+# use the following test, which should reliably enough detect whether
+# "C.UTF-8" is available:
+if locale -a | grep '^C' | grep -i utf --quiet; then
+  pref_lc=C.UTF-8
+else
+  pref_lc=C
 fi
 export LANG=en_US.UTF-8 LC_TIME=en_DK.UTF-8 LC_COLLATE=$pref_lc 
LC_CTYPE=$pref_lc
 # Instead of assigning those variables, this is generally preferable:



reply via email to

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