I've been using Environment variables for ages but only just read about Environment variables vs. Shell variables. According to the definition:
- Environment variables are "system-wide" and inherited by child shells and processes
- Shell variables are only valid in the shell in which they are set
The book I'm reading goes on to state that using export takes a variable in your current environment (bash shell) and makes it available in any every environment until you change it again.
But if I change an Environment variable (HISTSIZE, for example) by calling export HISTZISE=999
, and then check the value in a different terminal tab (echo $HISTSIZE
), the change isn't visible. Why is this if the change is supposed to be system-wide? Personally I'm used to always setting my Environment variables when opening a new terminal tab, and I had taken it for granted that exporting values wouldn't affect other tabs (shells?).
So my question is: Are different terminal tabs considered different shell environments? And what does "system-wide" then mean?
Thanks for the help!
echo $$
shows you process identifier of the current shell. You can check that the value is different in different tabs.