locale environment variables

Stainforth, Matthew (SD/DS) Matthew.Stainforth at gnb.ca
Sun Nov 22 20:55:27 UTC 2009


for me, setting LC_ALL and exporting it seems to do the trick to set all the LC_* variables in the locale and have it inherited when a new shell is spawned.  It should work if you set and export them at the end of your .profile.

This is fedora 12 but I will verify at work tomorrow that this still holds on RHEL5:

[matt at fedora ~]$ 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=en_US.UTF-8

## set the shell variable ##
[matt at fedora ~]$ LANG=zu_ZA.iso88591 
[matt at fedora ~]$ locale
LANG=zu_ZA.iso88591
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=en_US.UTF-8
[matt at fedora ~]$ export LANG
[matt at fedora ~]$ locale
LANG=zu_ZA.iso88591
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=en_US.UTF-8
[matt at fedora ~]$ LC_ALL=zu_ZA.iso88591
[matt at fedora ~]$ export LC_ALL
[matt at fedora ~]$ locale
LANG=zu_ZA.iso88591
LC_CTYPE="zu_ZA.iso88591"
LC_NUMERIC="zu_ZA.iso88591"
LC_TIME="zu_ZA.iso88591"
LC_COLLATE="zu_ZA.iso88591"
LC_MONETARY="zu_ZA.iso88591"
LC_MESSAGES="zu_ZA.iso88591"
LC_PAPER="zu_ZA.iso88591"
LC_NAME="zu_ZA.iso88591"
LC_ADDRESS="zu_ZA.iso88591"
LC_TELEPHONE="zu_ZA.iso88591"
LC_MEASUREMENT="zu_ZA.iso88591"
LC_IDENTIFICATION="zu_ZA.iso88591"
LC_ALL=zu_ZA.iso88591
[matt at fedora ~]$ bash
[matt at fedora ~]$ locale
LANG=zu_ZA.iso88591
LC_CTYPE="zu_ZA.iso88591"
LC_NUMERIC="zu_ZA.iso88591"
LC_TIME="zu_ZA.iso88591"
LC_COLLATE="zu_ZA.iso88591"
LC_MONETARY="zu_ZA.iso88591"
LC_MESSAGES="zu_ZA.iso88591"
LC_PAPER="zu_ZA.iso88591"
LC_NAME="zu_ZA.iso88591"
LC_ADDRESS="zu_ZA.iso88591"
LC_TELEPHONE="zu_ZA.iso88591"
LC_MEASUREMENT="zu_ZA.iso88591"
LC_IDENTIFICATION="zu_ZA.iso88591"
LC_ALL=zu_ZA.iso88591
[matt at fedora ~]$ printenv LC_ALL
zu_ZA.iso88591
[matt at fedora ~]$ printenv LANG
zu_ZA.iso88591
[matt at fedora ~]$ 


________________________________________
From: redhat-list-bounces at redhat.com [redhat-list-bounces at redhat.com] On Behalf Of hook [ls at utserver.net]
Sent: Saturday, November 21, 2009 2:27 PM
To: redhat-list at redhat.com
Subject: locale environment variables

I could use some help in understanding the process which RHEL systems
apply to the locale environment variables (specifically LANG and
LC_ALL).  It seems that from /etc/profile.d/lang.sh, LC_ALL is unset
unless it was already initialized to something other than the value of LANG.


     if [ -n "$LC_ALL" ]; then
        if [ "$LC_ALL" != "$LANG" ]; then
          export LC_ALL
        else
          unset LC_ALL
        fi
     else
        unset LC_ALL
     fi



I seem to have an application that requires these two variables to be
set to the same value, so instead of modifying the system wide profile
config, I decided to add the following to ~/.bash_profile since this app
runs under only one account:

    if [ "$LC_ALL" != "$LANG" ]; then
        LC_ALL=$LANG
        export LC_ALL
    fi


The problem I have now is that this app generates it own job submission
which basically runs a script that dynamically generates another script
for execution later.  I'm not a developer so I don't understand the
entire process, but without exporting these two variables inside the
first script, the LC_ALL variable is still being unset by the system
wide profile.  I don't know if this illustrates the same issue, but when
I establish an initial SSH session, I see the values set for both
variables as desired, however if I simply kick off another bash shell,
the LC_ALL is unset again.

$ 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=en_US.UTF-8
$ bash
$ 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=



Any explanation of why this is occurring or advise on how to change the
behavior would be appreciated.


Thanks,
Hook

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list




More information about the redhat-list mailing list