I’ve got a bash file where are defined a number of variables:
VAR1="value1"
VAR2="value2"
# ...
I need to import these variables in ~/.bashrc in order to customize PS1, PATH and so on, but don’t want that the imported variables can be accessed outside of ~/.bashrc.
To make myself clear with an example, I’d like to do something like this:
function setPATH
{
local . ~/bashvars.sh # this isn't legal, of course...
PATH="$PATH:$VAR1" # $VAR1 is defined in ~/bashvars.sh
unset -f setPATH
}
setPATH
How can I do this?
use a subshell: