From owner-freebsd-questions@freebsd.org Mon Jul 20 10:54:00 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E3BAF3599EA for ; Mon, 20 Jul 2020 10:54:00 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B9JWC4jbMz3YLT for ; Mon, 20 Jul 2020 10:53:59 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([94.222.26.105]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPA (Nemesis) id 1M597q-1jwMy73BSe-0019Fj; Mon, 20 Jul 2020 12:53:55 +0200 Date: Mon, 20 Jul 2020 12:53:55 +0200 From: Polytropon To: mbj@mbjnet.dk Cc: Morten Bo Johansen via freebsd-questions , Morten Bo Johansen Subject: Re: Locale oddity Message-Id: <20200720125355.4fd333bf.freebsd@edvax.de> In-Reply-To: References: <0467d480-ba58-3d5d-ca77-34d784b667f9@yuripv.dev> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:atx0mFcXiq/uK5zA4DZ/hse/Lsyd1NdulP3aEvuGcEzraFj9PxX JJGyVn4kbqtcXj+1XB8RAd81pXyoO8mRPmCpHpXN/rBGin+LIOdeocG0nzGNbS4XAExpYw6 Da/h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Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 217.72.192.75) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [2.45 / 15.00]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; NEURAL_HAM_SHORT(-0.32)[-0.319]; RECEIVED_SPAMHAUS_PBL(0.00)[94.222.26.105:received]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8560, ipnet:217.72.192.0/20, country:DE]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.26)[-0.262]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.63)[0.631]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[217.72.192.75:from]; R_SPF_NA(0.00)[no SPF record]; RWL_MAILSPIKE_POSSIBLE(0.00)[217.72.192.75:from]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jul 2020 10:54:01 -0000 On Mon, 20 Jul 2020 11:30:33 +0200, Morten Bo Johansen via freebsd-questions wrote: > On 2020-07-19 Yuri Pankov wrote: > > > I'm not sure what exactly you are asking, so I'll just quote the > > specification, > > https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html, > > for the logic used: > > Well, the reason I was asking was that I was working on a > script where one of the functions will determine the user's > language reliably from the locale settings. Therefore I tried > various error handling, like e.g. the LANG variable not being > set, etc. and I noticed this behaviour and I wondered why. I > see the rule #4 you are referring to, but the logic in it is > still not clear to me: Some script or program might set the > $LANG variable to an empty value and then the LC_* variables > that I set myself will be changed behind my back? No, the variables (being set, and how)won't affect one another. Rule #4 states that if $LANG is not usable (and no other information is present), the default "fallback locale" _should_ be used, which is "C". So the "hierarchy" is this: 1. LC_ALL 2. LC_* depending on category 3. LANG 4. fallback (usually "C") Just as an example, if you have not set $LANG, but you have set the several $LC_* variables, except $LC_ALL, rule #2 applies. With $LC_ALL set, all $LC_* variables will be overridden, as says rule #1. If no $LC_ is set, but $LANG is set, rule #3 applies. If there is nothing set, rule #4 says to use the implementation-specific locale, which usually is "C". So the $LC_* variables you've set yourself will always keep their value. The question simply is: Will a program use them according to the standard? A program _might_ do the wrong thing and even though you have set $LC_MESSAGES to "da_DK.UTF-8", but the program expects and only reads $LANG, it could say something like "no locale found, falling back to 'C' locale", which of course is _not_ the correct (!) thing to do... :-) The common solution is: Use LC_ALL to define all locale types with the same value. Use LC_* variables individually, but do not set LC_ALL, if you want to have different locale interpretations for different things, like collation information or decimal notation according to your local language, but messages in English. Optionally set LANG to the value of LC_ALL. Sidenote: You can use the login.conf mechanism to have the system set the variables for you; for example in ~/.login_conf: me:\ :charset=UTF-8:\ :lang=de_DE.UTF-8: This should work as expected. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...