diff --git a/.zshenv b/.zshenv index 88c81d1..e064a54 100644 --- a/.zshenv +++ b/.zshenv @@ -30,6 +30,47 @@ export DEBEMAIL=hjp@hjp.at export DEB_SIGN_KEYID=4ED25B463C8FC154D8189E64F20E485112FE285D export ACK_COLOR_FILENAME='blue on_white' +# Fix up locale. Must do this early or we get a lot of warnings if a +# locale isn't installed. +# Assume that locale and grep are in the PATH. + +case "`uname -sr`" in +Linux*) + export LC_COLLATE=POSIX + if [ -z "$LANG" ] + then + utf=`locale -a | grep en_US.utf8` + if [ -n "$utf" ] + then + # this is a bit of a hack - + # locale -a advertises the locale as "en_US.utf8", + # but the glibc accepts both "en_US.utf8" and + # "en_US.UTF-8" and xterm recogizes only the latter. + # So we explicitely set the latter, even though that's + # not the canonical name and may break some day. + # + LANG=en_US.UTF-8 + else + # fall back to latin 1. + LANG=en_US.iso88591 + fi + export LANG + fi + for i in LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL + do + c=$(eval "echo \$$i") + if [ -n "$c" ] + then + r=$(locale -a | grep "${c/UTF-8/utf8}") + if [ -z "$r" ] + then + unset $i + fi + fi + done + ;; +esac + # don't rely on a sane path at this point: for i in /usr/bin/preppath /usr/local/bin/preppath @@ -65,32 +106,6 @@ then unsetopt NULL_GLOB fi -case "`uname -sr`" in -Linux*) - export LC_COLLATE=POSIX - if [ -z "$LANG" ] - then - utf=`locale -a | grep en_US.utf8` - if [ -n "$utf" ] - then - # this is a bit of a hack - - # locale -a advertises the locale as "en_US.utf8", - # but the glibc accepts both "en_US.utf8" and - # "en_US.UTF-8" and xterm recogizes only the latter. - # So we explicitely set the latter, even though that's - # not the canonical name and may break some day. - # - LANG=en_US.UTF-8 - else - # fall back to latin 1. - LANG=en_US.iso88591 - fi - export LANG - fi - # export LC_TIME=de_AT # don't remember what that was for - ;; -esac - case "$LANG" in *.iso88591) export LESSCHARSET=latin1