change environment variable in child process - bash

bash, environment-variables

Solution

In `a.sh` do `source b.sh` instead of `./b.sh`

`a.sh` should look like this :

#!/bin/bash
export A=1
source b.sh
echo parent "$A"

Problem

Hi I have following example. a.sh script sets environment variable which I can see in b.sh (child) script, but if I change it I still have the old value in a.sh a.sh ``` #!/bin/bash export A=1 ./b.sh echo parent $A ``` b.sh ``` #!/bin/bash echo child $A A=2 export A echo child $A ``` test: ``` bash-3.00$ ./a.sh child 1 child 2 parent 1 child 1 child 2 ```

Original source