[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: setenv
Well, it seems I was a bit mistaken about the Bourne Shell (sh, bash). Let me make the "EXPORT" stuff clearer:
The bourne shell does keep its own set of variables which are separate from the environment variables. If you initialize a new variable that is non-existant in the environment it will not appear there. E.g:
# NEWVAR="Hello World"
# printenv | grep NEWVAR
will not print anything. In order to place the variable within the environment you can execute the command:
# export NEWVAR
and afterwards printenv will show it too.
Now, the "$VARIABLE" syntax extracts the value of an environment variable with the name VARIABLE, and only if no such env. variable exist it presents the value of the shell inner variable with that name (or nothing if it doesn't exist either).
If a variable already exists in the environment then the "VAR=VALUE" command will modify the environment variable. Otherwise, it changes its value in the shell private cache.
The "export VAR" command is required to pass variable to child scripts, because otherwise the variable VAR will remain only in the shell private variables which are not inherited by them.
Messy, isn't it?
Shlomi Fish
Follow-Ups:
- Re: setenv
- From: Eliyahu Skoczylas <eliyahu@photonet.com>