0
We know that we can change bash's environment variables, for example PATH
, using initialize script, for example .bashrc
. Just writing PATH=<VALUE>
and you will get what you want.
But, consider this problem:
We have a bash script named rc
:
#!/bin/bash
mySite="superUser"
export mySite
echo "the value of mySite is: $mySite"
Then we declare the variable mySite
, execute the rc
script, and then check the the variable's value:
$ declare -x mySite="super"
$ ./rc
the value of mySite is: superUser
$ echo $mySite
super
The value is still super
. can we conclude that child shell cannot change parent shell's variable directly using the instruction like VARIALBENAME=VLAUE
?
Our rc
script is just like .bashrc
, and how can we change the bash's environment variable's value by placing the PATH=<VLAUE>
in it, for when .bashrc
's execution is over, the variable of the calling shell is still not changed?