bug-bash
[Top][All Lists]
Advanced

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

Re: Warning raised if trying to set LC_ALL to a locale bearing a charact


From: Chet Ramey
Subject: Re: Warning raised if trying to set LC_ALL to a locale bearing a character type other than UTF-8 and C
Date: Wed, 6 Jul 2022 09:37:06 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 7/1/22 9:08 AM, Kerin Millar wrote:
> Hello,
> 
> I was experimenting with locale variables in bash and noticed something that 
> appears odd. This is with bash 5.1.16 and glibc 2.35.
> 
> $ locale -a | grep -E '^en_(US|GB)'
> en_GB.utf8
> en_US
> en_US.iso88591
> en_US.utf8
> 
> $ locale
> LANG=en_US.UTF-8
> LC_CTYPE="en_US.UTF-8"
> LC_NUMERIC="en_US.UTF-8"
> LC_TIME="en_US.UTF-8"
> LC_COLLATE="en_US.UTF-8"
> LC_MONETARY="en_US.UTF-8"
> LC_MESSAGES="en_US.UTF-8"
> LC_PAPER="en_US.UTF-8"
> LC_NAME="en_US.UTF-8"
> LC_ADDRESS="en_US.UTF-8"
> LC_TELEPHONE="en_US.UTF-8"
> LC_MEASUREMENT="en_US.UTF-8"
> LC_IDENTIFICATION="en_US.UTF-8"
> LC_ALL=
> 
> $ ( LC_ALL=en_US.ISO-8859-1 )
> bash: warning: setlocale: LC_ALL: cannot change locale (en_US.ISO-8859-1)

Bash prints a warning if setlocale(3) returns an error (a null string) to
inform the user that even though they changed the shell variable, the
global locale wasn't changed correspondingly. Since there are no errors
defined for setlocale(), it's perfectly reasonable for it not to change
errno, so there's no additional error message if errno stays 0.

You can look at locale.c:set_locale_var() for the details.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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