From 956f4f46f180891eb474531cc93e2f4961d74939 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 26 Jun 2019 16:20:53 +0200 Subject: bash: check if the locale actually exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- bashrc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bashrc b/bashrc index 2ebe76f..0a03e7d 100644 --- a/bashrc +++ b/bashrc @@ -2,7 +2,16 @@ # Locale. # Set LC_ALL always to UTF-8. -export LC_ALL=ca_ES.UTF-8 +if [ "$(locale -a | grep ca_ES.utf8)" != "" ]; then + export LC_ALL=ca_ES.utf8 +else + if [ "$(locale -a | grep en_US.utf8)" != "" ]; then + export LC_ALL=en_US.utf8 + else + echo "[Warning] Could not set up a proper locale." \ + "There is probably something missing on your host machine..." + fi +fi ## # Basics. @@ -148,4 +157,4 @@ alias ssh="gpg-connect-agent updatestartuptty /bye >/dev/null; ssh" # Handy alias for the ip command alias ip="ip --color" -alias ipb="ip --color --brief" \ No newline at end of file +alias ipb="ip --color --brief" -- cgit v1.2.3