bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setting locales


From: Chet Ramey
Subject: Re: setting locales
Date: Mon, 7 Jul 2008 08:23:03 -0400

> In file locale.c, function get_locale_var,     locale = 
> default_locale;    /* system-dependent; not really portable.  should it 
> be "C"? */
> default_locale contains string returned by calling 
> setlocale(LC_ALL,NULL); and we then use this string to assign locale for 
> LC_'every_other' and this is not right way. Why we simple don't call 
> setlocale(LC_ALL,default_locale)? The final code will be shorter and 
> more readable...

Bash does most of the locale-setting itself for two reasons.

1.  setlocale() calls getenv() to obtain the values for the variables it's
    interested in.  Not all systems allow getenv() to be replaced or
    interposed, so setlocale() would see stale data.

2.  Users expect shell variables to affect the locale for the shell.  Since
    setlocale() looks in the environment, these changes would not be
    applied.

In any event, calling setlocale(LC_ALL, default_locale) is rarely the right
thing to do, since it doesn't allow users to mix locales between categories
(e.g., LC_COLLATE=C; LC_CTYPE=C; LC_MESSAGES=de_DE.UTF-8).

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://tiswww.tis.case.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]