4.3.5 Command execution and environment variable
Typical command execution uses a shell line sequence like the following: [28]
$ date
Sun Oct 26 08:17:20 CET 2003
$ LC_ALL=fr_FR date
dim oct 26 08:17:39 CET 2003
Here, the program date
is executed in the foreground job. The
environment variable LC_ALL is:
-
unset (system default, same as C) for the first command
-
set to fr_FR (French locale) for the second command
Most command executions usually do not have preceding environment variable
definition. For the above example, you can alternatively execute:
$ LC_ALL=fr_FR
$ date
dim oct 26 08:17:39 CET 2003
As you can see here, the output of command is affected by the environment
variable to produce French output. If you want the environment variable to be
inherited to the subprocesses (e.g., when calling shell script), you need to
"export" it instead by using:
$ export LC_ALL