Somebody told me that:
BASH isn't an environment variable, it's a shell variable
What's the difference?
|
Somebody told me that:
What's the difference? |
|||
|
|
|
Environment variables such as For an explanation of environment variables see Environment Variables in Ubuntu Help. |
|||||||||
|
|
To answer this question first try to understand scope of a variable. When you create a new variable like When you export that variable like
Analogy: let's assume you have a two-bedroom apartment and you are sharing it with another roommate. The common area can be accessed by anyone but not your bedrooms, environment variable is like common area and shell variable is like bedroom, if you will something in common area it can be accessed by anyone but if you keep it in your bedroom it can only be accessed by you. Remember if open a new terminal you won't be able to access either of the variables because you are changing that instance. For that you should add your variables in either |
||||
|
|
|
Shell Variable: Short Term, Applied only to current instance of the shell, Not applicable system wide Environmental Variable: Long Term Usage, Valid System Wide, Globally Allowed By convention Shell Variable have their name as lowercase while Envn. Variables are written as uppercase |
|||
|
|
|
There is a difference. Shell Variables and Environment Variables will explain it better that I can, but here is an excerpt from it:
|
|||||||||
|
|
An environment variable is a globally available, in a program and it child programs. A shell variable is only available in the current shell. To make a shell variable available as an environment variable, use Examples for clarification:
Another way to define an environment variable:
|
|||||||||
|