change environment variable in child process - bash -
hi have following example. a.sh script sets environment variable can see in b.sh (child) script, if change still have 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 echo child $a
test:
bash-3.00$ ./a.sh child 1 child 2 parent 1 child 1 child 2
in a.sh
source b.sh
instead of ./b.sh
a.sh
should :
#!/bin/bash export a=1 source b.sh echo parent "$a"