pipe.sh
export START=100
. ./other.sh &
wait
other.sh
sleep 5
export END=200
but I dont see the variable END in "export -p". But I do see it if change the pipe.sh to
export START=100
. ./other.sh
how do I export variables from background process? Any work arounds?
A child process cannot change parents environment, you need to declare the variable from the parent somehow. For example using a file:
pipe.sh:
other.sh:
Also see this answer.