Thread
:
How to source ~/.profile through a script with effects lasting after the script has run?
View Single Post
白い熊
2011-09-01 , 14:07
Posts: 451 | Thanked: 334 times | Joined on Sep 2009
#
1
I have customized PATH, CFLAGS, etc many variables in .profile, which get changed dynamically upon copying files to certain directories.
After I do this, to make the system aware, I source ~/.profile again, which makes it reread these dirs.
I've been busting my brains, how to call:
Code:
. ~/.profile
from a shell script and have the exported environment variables stay in the system, after this shellscript has run. Can anyone help me?
What I mean is, for instance: say .profile reads ~/bin for subdirs and then adds these to the PATH
So I source it now, it only has one subdir, so only ~/bin/1 gets added to the PATH
Let's say I create ~/bin/2, and now I need to source ~/.profile to add ~/bin/1 and ~/bin/2 to PATH
If I open a terminal and run
Code:
. ~/.profile
all's fine and the PATH contains the proper dirs.
But if I create a shell script with just
Code:
. ~/.profile
and then run
Code:
./shellscript.sh
the PATH gets exported within the script, but once it finishes running the PATH in the term is obviously not affected by the export.
I want to source .profile in a shellscript somehow and have the resultant exported variables remain exported after the shellscript has finished running.
Can I do this somehow? Can't figure out how...
Thanks for advice.
Quote & Reply
|
白い熊
View Public Profile
Send a private message to 白い熊
Find all posts by 白い熊