I want to get a variable from another script, as demonstrated in this question on Stack Overflow:
How to reference a file for variables in a bash script
However, the answer uses the source
command which is only available in bash
. I want to do this in a portable way.
I have also tried
a.sh
export VAR="foo"
echo "executing a"
b.sh
#!/bin/sh
./a.sh
echo $VAR
But of course that does not work either. How to do this?