Paul Eggert <[email protected]> writes:
> On 2026-12-02 14:43, Collin Funk wrote:
>>> 2. (optionally) through a setlocale() override that falls back to
>>> the "C" locale when asked to activate one of the locales mentioned
>>> above.
>> I'm a bit concerned about silently doing that, since the program would
>> behave unexpectedly.
>
> It's what the programs already do when the locales are not installed,
> which is the typical case, right? If so, the behavior is typical
> already.
Sort-of, yes. But my concern is that someone has a locale installed
using those encodings, and uses them for some reason. In that case, it
seems wrong to silently change the locale changing the behavior
unexpectedly. This feels different than silently reverting to the C
locale if the given locale doesn't exist, or is not installed. If that
makes sense.
I notice that bash does warn with the export builtin though:
$ (export LC_ALL=abc)
-bash: warning: setlocale: LC_ALL: cannot change locale (abc): No such file
or directory
This doesn't help in the case of invocations like this, though:
$ LC_ALL=abc cut -w -f1 </dev/null
Perhaps we could warn on setlocale failures?
Collin