export
is confusing. It really means mark-for-export
.
It implies child processes will later be created, and that's when the actual exporting will be done.
The export
order of events is: 1-ASSIGN, MARK, and ... 2-FORK.
1) Create a new local shell variable, assign the value to it, and mark this variable for later export.
2) Then if and when, the current shell script is FORKED, (i.e. to create and run any child-processes), then start a child process with a COPY of this exported variable, as one of it's many environment variables.
nb (note well): Not until step 2, and possibly long after the export
declaration was issued, does the variable actually get exported. So: export
only marks LANG. It does not export LANG.
By convention, exported variables are named in upper case.
Because LANG is only a copy, if the child later modifies this variable, it only modifies it for itself. The parent doesn't see the child's modifications.
Note that there are also many other environment variables passed to child processes from parent processes. These include all of the other environment variables that the parent process also gets from it's parent.
So the child inherits all of the parent's environment variables,
+ any additional ones that the parent marks for export
,
- less any variables which are explicitly unset
.
In other words, we have two processes to think about: the parent process and any future child process(es).
The process you're running, in this case profile
, is what we're calling the 'parent process'.
profile
can spawn one or more child processes, like for example if one of the things you do in profile is to run a program. That program is then (normally) run as a child process of profile
. (This is not true if the file is sourced in profile, using the . <name>
or source <name>
notation, where what is sourced runs in the same process as profile
.)
export LANG=ru_RU.UTF-8
export LC_CTYPE=ru_RU.UTF-8
export LC_ALL=ru_RU.UTF-8
So now let's look at the effects of these three environment variables.
LANG is what a user normally sets to affect the language that a program runs in. When in terminal if you enter env | grep LANG
you should see that LANG is set to your <language>_<country-code>.<character-encoding>
, e.g. LANG=en_US.UTF-8.
LC_CTYPE is an override to LANG, and overrides just the character set used. All other features (categories) of LANG are still used as set by LANG, e.g. LC_TELEPHONE.
LC_ALL is a further override. It overrides both LC_CTYPE and all locale categories that were set by LANG to a given language and codeset. Note that LC_ALL should never be set persistently, like for a profile itself. It is intended only as a temporarily entire locale override, i.e. it overrides all categories, like LC_TELEPHONE, LC_MONETARY, LC_CTYPE, etc.