LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Export PATH (https://www.linuxquestions.org/questions/linux-newbie-8/export-path-765135/)

scucci 10-28-2009 05:18 PM

Export PATH
 
I was just reading about the command "Export PATH" and wasn't quite sure why this had to be done? This has confused me in the past.

Thanks.

pljvaldez 10-28-2009 05:42 PM

Basically you only have to export your path if you change it. Otherwise, changes won't take effect until after a logout/login.

lwasserm 10-28-2009 05:44 PM

After you set a path it will be used by the current shell. If you don't export that path, any programs you run from the current shell will inherit the PATH that existed when the current shell was started. This applies to other variables as well. When you export PATH or export VARIABLE in general, that variable is available in the environment of the programs you run from the current shell. I agree it can be confusing at first, but after you work with the concept a little while it will seem natural and logical.

chrism01 10-28-2009 08:14 PM

Not quite; any setting in the current shell (ie not exported) will be picked up by programs in the current shell level, but not by any sub-shells. What export does is 'export' (sic) those variables to all sub-shells/envs created from that shell ie unless you call a shell by

source x.sh

OR

. x.sh

non-exported vars will not be avail to the new shell.

http://www.ibm.com/developerworks/library/l-bash.html


All times are GMT -5. The time now is 07:26 AM.