pipe.sh
export START=100
. ./other.sh &
wait
other.sh
sleep 5
export END=200
But I don’t see the variable END in export -p. If I source other.sh in the foreground it works though.
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.