Subject: Re: userlevel tools and setlocale(3)
To: None <>
From: Aleksey Cheusov <>
List: tech-userlevel
Date: 04/28/2006 17:56:06
> On Thu, Apr 27, 2006 at 09:53:56PM +0300, Aleksey Cheusov wrote:
 >> What do you think about the following patch for nawk?
 >> With this patch applied, awk will exit with error
 >> if LANG or LC_ variable are set to incorrect value,

> Incorrect locale settings are softerrors, since it is entire
> possible that a single part of a locale is not defined. setlocale()
> is well-behaving in that regard, it falls back to "C", as if nothing
> had happened.
With this "softerror" scripts that rely on locale
work _completely_ incorrect with no chance of signaling
user about errors.

> Changing this would just push the work to the user.
I'm a user ;-) And I have _lots of_ scripts that rely on non-C
locales including utf-8 ones (LC_CTYPE part only is needed for me).
Now, while porting them to netBSD and openBSD from Linux,
I see that all they fail because not all required locales are installed.
As a user I would like to be signalled about these mistakes
as soon as they happen, not days or weeks later.
As far as I know, most of programs
don't check return value of setlocale(3) function and I think that
this is a very bad practice.
This problem is presumedly new to developers because they ignored
return value of setlocale(3) for years.
If you think that most of users will be unhappy with
these changes, they may be optional depending of environment variable.
Users like me who need strict behaviour will switch it on in ~/.profile
or somewhere.

Best regards, Aleksey Cheusov.