I constructed a simple example to illustrate the problem:
caller.sh:
#!/usr/bin/env bash
state="loaded"
source "sh/callee.sh" 2>&1
echo "$state"
callee.sh:
#!/usr/bin/env bash
state="integrated"
when I run caller.sh, it gives the result I want:
integrated
But if I add a pipe after the source command:
caller.sh:
#!/usr/bin/env bash
state="loaded"
source "sh/callee.sh" 2>&1 | cat
echo "$state"
The result becomes:
loaded
Question: How can I preserve/retrieve the changed value of $state in caller.sh?
catin the first place?