Export LC_ALL=POSIX but LANG value is not changed

Hi:

I use Fedora 40.
Now the execution result of locale command on my system is:

$ 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=

But when I enter export LC_ALL=POSIX in the terminal and execute the locale command again, the result is as follows:

$ locale
LANG=en_US.UTF-8
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=POSIX

You can see that all LC_* formats have been successfully changed to POSIX, but LANG still remains en_US.UTF-8.

But according to The Single UNIX ® Specification, the priority level of LC_ALL should be higher than LANG. Why is the value of LANG not changed after modifying LC_ALL? Do I need to execute export LANG=POSIX again?

Thanks

Is LANG being explicitly set by something else?

2 Likes

I think LANG is a legacy setting I think and not related to the LC_xxx variables.

3 Likes

Thank you for your reply.

So can I assume that even though LANG still shows up as en_US.UTF-8, the locale on the system is set to POSIX at this time?

Thanks for your reply.

There is only one line LANG=“en_US.UTF-8” in my /etc/locale.conf file

Do you use KDE Plasma? If so, you might want to check its config file ~/.config/plasma-localerc

2 Likes

man 7 locale says this:

  If the second argument to setlocale(3) is an empty string, "", for  the
   default locale, it is determined using the following steps:

   (1)  If  there  is a non-null environment variable LC_ALL, the value of
        LC_ALL is used.

   (2)  If an environment variable with the same name as one of the  cate‐
        gories  above  exists  and is non-null, its value is used for that
        category.

   (3)  If there is a non-null environment variable  LANG,  the  value  of
        LANG is used.
1 Like

Thanks for your reply.

I use Gnome

Here’s the related Fedora documentation:
System Locale and Keyboard Configuration :: Fedora Docs

GNOME also provides account specific settings:

busctl call org.freedesktop.Accounts \
    /org/freedesktop/Accounts/User${UID} \
    org.freedesktop.Accounts.User \
    SetLanguage s "en_US.UTF-8"
1 Like

It is assumed these days that the file system is using UTF-8 for filenames.
Setting POSIX may give you issues with that.

Settings a locale like POSIX or C is usually done just for specific commands, not the whole system.

2 Likes

Yes.

But when I try to add LC_ALL=de_DE.UTF-8 to the .bash_profile file and log in again, I will receive the following prompt. It seems that the language setting has indeed been changed to German
image

But when I enter the locale command in the shell, I can still find LANG=en_US .UTF-8
image

It seems that no matter what language system LC_ALL is changed to, the value of LANG will still not be changed.

You can set C.utf8 to get C or Posix locale with utf8 support.

1 Like

Added gnome