aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-09 00:15:53 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-09 00:15:53 +1300
commit523fc2d8d7f8fd518f95762b116a150d351af7e3 (patch)
treefae8ffa971de55e8c9d50b321282eea0121ad33b /sh/profile.d
parentRemove resolved issue (diff)
downloaddotfiles-523fc2d8d7f8fd518f95762b116a150d351af7e3.tar.gz
dotfiles-523fc2d8d7f8fd518f95762b116a150d351af7e3.zip
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.
Diffstat (limited to 'sh/profile.d')
-rw-r--r--sh/profile.d/lang.sh15
1 files changed, 15 insertions, 0 deletions
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