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 c...@case.edu http://tiswww.cwru.edu/~chet/