On 8/7/07, Mike McCarty <Mike.McCarty@sbcglobal.net> wrote:
I do believe he's got it... almost.
Errr... She :-)
If ENV_VAR is an environment variable, then the shell interprets
$ENV_VAR as a request to remove $ENV_VAR from the command, and replace
it with the value of ENV_VAR. So...
$ ENV_VAR1="Fred Flintstone"
$ ENV_VAR2=$ENV_VAR
sets ENV_VAR2 to be the value of ENV_VAR at the time of the assignment,
or "Fred Flintstone".
$ ENV_VAR2=ENV_VAR
sets ENV_VAR2 to be "ENV_VAR1".
This is confusing me. I understand that if ENV_VAR is an environment variable
than $ENV_VAR represents ENV_VARs value.
But this I don't understand:
$ ENV_VAR1="Fred Flintstone"
$ ENV_VAR2=$ENV_VAR
sets ENV_VAR2 to be the value of ENV_VAR at the time of the assignment,
or "Fred Flintstone".
Did you mean
$ ENV_VAR2=$ENV_VAR1
(notice the 1 at the end)? If so, than it's clear. Or was the value of ENV_VAR
at the time of the assignment also "Fred Flintstone", so that both ENV_VAR
and ENV_VAR1 have the same value? Or do you mean that ENV_VAR1 &
ENV_VAR2 are subsequent values of ENV_VAR?
$ PATH=xyz:$PATH
sets PATH (not $PATH) to be the string "xyz:" followed by
the value PATH had before the assignment took place.
OK, this is clear.
You might also look into the use of ~/.bashrc
BTW, it's common to use $HOME instead of "~" as not all tools
know to expand it when it is used in environment variables.
Like this:
$ export PATH=$HOME/scripts:$PATH
OK, done. Didn't know that either.
Greetings and many thanks for explaining, Manon.