From d08ee7b1f0ae2bbd3491939557032c6117807dae Mon Sep 17 00:00:00 2001 From: memdmp Date: Fri, 17 Jan 2025 19:25:23 +0100 Subject: feat: ensure LANG and LC_ALL are set --- env.zsh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'env.zsh') diff --git a/env.zsh b/env.zsh index 9c49ea4..04d1be4 100644 --- a/env.zsh +++ b/env.zsh @@ -7,4 +7,18 @@ # memdmp # -# Currently empty, however this may change at a later date to, for example, load a .config/env & .config/env.d/, or similar. +# Currently, we just ensure your environment is sensible - e.g. we ensure your LANG is well-defined, etc... +if [[ "$VALIDATE_LANG" != "false" ]]; then + if [[ "$LANG" == "" ]] || [[ "$LANG" == "C" ]]; then + # Modern systems will have UTF-8 everywhere outside of a TTY. + # Login Shells are the only shell likely to be a TTY (although theoretically other shells could also be login shells, but like idc if 1% of thigns break). + if [[ "$-" == *l* ]]; then + export LANG="C.UTF-8" + else + export LANG="C" + fi + fi + if [[ "$LC_ALL" == "" ]] || [[ "$LC_ALL" == "C" ]]; then + export LC_ALL="$LANG" + fi +fi -- cgit v1.2.3