If I understood this requirement, then both scenarios cannot simply be executed in the same subcommand independently of each other, but without , calling each other, or without the need to use an external file or channel as follows:
Let's say this is your script1.sh
#!/bin/bash # script1.sh: do something and finally export x=19
And here is your script2.sh
#!/bin/bash # script2.sh: read value of $x here echo "x="${x}
Just name them in the same sub-shell like this
(. ./script1.sh && ./script2.sh)
CONCLUSION:
x=19
source share