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

Re: Does "LC_ALL=C" work on all shells?



On Tue, Feb 13, 2024 at 01:21:20PM -0800, John Conover wrote:
>     egrep ALL .bashrc
>     LC_ALL=C

This has gone pretty far off the rails, but here we are.  Let's address
this.

DO NOT set LC_ALL in your .bashrc or equivalent files.  This is a horrible
idea.  LC_ALL should only be used in single commands as a full-powered
override, for example when you want to report a bug, and need the output
to be normalized to the "C" locale.

In your everyday operations, you should use the LANG variable for the
locale that most closely matches your needs, and individual LC_*
variables (such as LC_TIME) for specific overrides.  Setting it up this
way allows you to override with LC_ALL when needed, *and* it allows you
to fine-tune your preferences.

For example, let's say you wanted the C locale for most things, but
the en_US.utf8 locale for one particular setting (let's say LC_TIME).
You can do this with:

    LANG=C LC_TIME=en_US.utf8

but if you try it this way:

    LC_ALL=C LC_TIME=en_US.utf8

then it won't work, because LC_ALL overrides everything.  Your LC_TIME
setting will have no effect.

Of course, *none* of this is relevant to the original question, which
was about the shell syntax for overriding environment variables on a
single command.


Reply to: