user3011448
user3011448

Reputation: 7

I don't see the difference export makes in BASH

In my .bash_profile, I added a new path into $PATH and exported it so that I am able to run scripts in that directory.

However, when I removed the word "export", reopened the terminal and launched a new shell, I was still able to run those scripts.

I do understand that export makes a variable visible to subprocesses, but as you can see, here it does not really make a difference.

Can someone explain to me why? Thanks in advance.

Upvotes: 1

Views: 179

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798676

.bash_profile is sourced into the shell. As such, the variables do not need to be exported for use in the shell. However, if you run a non-shell (e.g. C or Python) program that uses exec*p*(3) then they won't have access to the new value of $PATH and may fail.

Upvotes: 3

Related Questions