From 523fc2d8d7f8fd518f95762b116a150d351af7e3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jan 2017 00:15:53 +1300 Subject: Force LC_COLLATE to a sane value It always really annoys me when e.g. the leading dot or leading slash in pathnames or filenames gets ignored for the purposes of sorting. I may refine this later on but it seems like a good start for an approach. --- sh/profile.d/lang.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sh/profile.d/lang.sh (limited to 'sh') diff --git a/sh/profile.d/lang.sh b/sh/profile.d/lang.sh new file mode 100644 index 00000000..44d1cefa --- /dev/null +++ b/sh/profile.d/lang.sh @@ -0,0 +1,15 @@ +# Use the system's locale and language, but if it's not C or C.UTF-8, then +# force LC_COLLATE to an appropriate C locale so that the order of sort and +# glob expansion stays sane without making e.g. dates insane. Don't interfere +# at all if LANG isn't even set. +case $LANG in + C|C.UTF-8) ;; + *) + if locale -a | grep -q C.UTF-8 ; then + LC_COLLATE=C.UTF-8 + else + LC_COLLATE=C + fi + export LC_COLLATE + ;; +esac -- cgit v1.2.3