-
Notifications
You must be signed in to change notification settings - Fork 27
Description
On POSIX systems, environment variables such as LC_COLLATE influence the behavior of the setlocale() function in C, with the LC_ALL environment variable taking precedence over any other LC_xxx environment variables.
The LANG environment variable is used as a fallback in the event that one of the specific LC_xxx environment variables are unset.
See the Internationalization Variables section in SUSv3 for more information about how these environment variables can affect things.
The LC_COLLATE category matters when working with readline's filename completion and when filenames are sorted by utilities like ls.
It also affects the POSIX glob() function and wildcard expansion as a result.
For example, a partially patched es might do things like this:
; local (LC_COLLATE=C) { ls ; echo * }
A B a b
A B a b
; local (LC_COLLATE=en_US.UTF-8) { ls ; echo * }
a A b B # ok - external binary
A B a b # not ok - wildcard expansion should be affected
Similarly, functions like isprint() in Sconv() are affected by the LC_CTYPE category, and the strings accepted as "yes" or "no" by some utilities may be affected by the LC_MESSAGES category:
; locale yesstr
yes:y:YES:Y
; local (LC_MESSAGES = de_DE.UTF-8) { locale yesstr }
ja:j:JA:J:yes:y:YES:Y
This is one of those hidden corners of shell implementation that nobody thinks about until it rears its head.