On Wed, Nov 13, 2024 at 13:48:18 -0800, Yuri wrote: > # source is piped into tee > source child.sh | tee /dev/null > echo "XVAR=$XVAR" > echo "YVAR=$YVAR" > > # source is un-piped > source child.sh > echo "XVAR=$XVAR" > echo "YVAR=$YVAR"
> The first 'source' command didn't set variables set or exported in the > child.sh script, even though 'source' is executed in the current script's > context, and it should behave as if these commands were executed in-place. The commands within a pipeline are executed in subshells (child processes), so all variable changes are discarded when the subshell exits. See: https://mywiki.wooledge.org/BashFAQ/024 https://mywiki.wooledge.org/BashFAQ/106