Some systems (tested with macOS 10.12) auto-correct the output of LC_xxx
variables when using the locale(1) tool and the locale isn't supported:
$ LANG=de locale
LC_MESSAGES="de"
vs.
$ LANG=de locale
LC_MESSAGES="C"
So try to detect and revert this.
# tset(1) behaviour.
while true; do
lc_messages=$(locale 2>/dev/null | fgrep LC_MESSAGES | cut -d'=' -f2)
# tset(1) behaviour.
while true; do
lc_messages=$(locale 2>/dev/null | fgrep LC_MESSAGES | cut -d'=' -f2)
+ [[ "$lc_messages" = '"C"' && "$LANG" != 'C' && "$LC_ALL" != 'C' ]] && lc_messages=$LANG
lc_messages=$lc_messages:gs/\"//
locale=$lc_messages:r
[[ "$OSTYPE" = 'linux-gnu' && $locale != 'C' ]] \
lc_messages=$lc_messages:gs/\"//
locale=$lc_messages:r
[[ "$OSTYPE" = 'linux-gnu' && $locale != 'C' ]] \