Date: Sun, 19 Jul 2020 19:57:31 +0200 From: Polytropon <freebsd@edvax.de> To: mbj@mbjnet.dk Cc: Morten Bo Johansen via freebsd-questions <freebsd-questions@freebsd.org>, Morten Bo Johansen <listmail@mbjnet.dk> Subject: Re: Locale oddity Message-ID: <20200719195731.66f8ea30.freebsd@edvax.de> In-Reply-To: <slrnrh8vv3.j55.listmail@smtp.simply.com> References: <slrnrh8vv3.j55.listmail@smtp.simply.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 19 Jul 2020 19:14:44 +0200, Morten Bo Johansen via freebsd-questions wrote: > If I unset the $LANG variable, then all other LC_* category > locale variables will automatically be set to "C" except for > the $LC_ALL variable: > > ~/ % LANG= locale > LANG= > LC_CTYPE="C" > LC_COLLATE="C" > LC_TIME="C" > LC_NUMERIC="C" > LC_MONETARY="C" > LC_MESSAGES="C" > LC_ALL= > > Otherwise they are: > > ~/ % locale > LANG=da_DK.UTF-8 > LC_CTYPE="da_DK.UTF-8" > LC_COLLATE="da_DK.UTF-8" > LC_TIME="da_DK.UTF-8" > LC_NUMERIC="da_DK.UTF-8" > LC_MONETARY="da_DK.UTF-8" > LC_MESSAGES="da_DK.UTF-8" > LC_ALL= > > I don't understand this behaviour. Could someone explain the > logic of this to me? There is a certain "precedence" in the language variables: IF $LANG is set, all others are ignored; if $LC_ALL is set, all other $LC_*s will be ignored. You can find more information in "man 3 setlocale": Only three locales are defined by default, the empty string "" which denotes the native environment, and the "C" and "POSIX" locales, which denote the C language environment. [...] By default, C programs start in the "C" locale. The Handbook also has detailed information in section 22.2. https://www.freebsd.org/doc/handbook/using-localization.html So what you see is correct and expected: All $LC_* variables except $LC_ALL will default to "C", otherwise they will inherit what $LANG contains; $LC_ALL will not be set automatically to anything. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200719195731.66f8ea30.freebsd>
