I defined some environment variables in my .profile like this:
MY_HOME="/home/my_user"
but the variable does not seem to evaluate unless I strip off the quotes and re-source the file. I believe the quotes are necessary if there will be spaces, and single quotes are used if escapes are not desired. Can someone clarify the significance of single and double quotes in variable definitions? How about front-ticks and back-ticks?
Best Answer
I think you're confused about terminology.
An "environment variable" is merely a shell variable that any child processes will inherit.
What you're doing in your example is creating a shell variable. It's not in the environment until you export it:
puts a variable named "MY_HOME" in almost all shells (csh, tcsh excepted).
In this particular case, the double-quotes are superfluous. They have no effect. Double-quotes group substrings, but allows whatever shell you use to do variable substitution. Single-quoting groups substrings and prevents substitution. Since your example assignment does not have any variables in it, the double-quotes could have appeared as single-quotes.
Nothing is in the environment until you export it.