If I want to inherit environment variables to child processes, i do something like:
export MYVAR=tork
Assume I have a a file site.conf
Run set -a
before sourcing the file. This marks all new and modified variables that follow for export automatically.
set -a
source site.conf
set +a # Require export again, if desired.
The problem you observed is that the pipe executes the export
in a subshell. You can avoid that simply by using input redirection instead of a pipe.
while read assignment; do
export "$assignment"
done < site.conf
This won't work, however, if (unlikely though it is) you have multiple assignments on one line, such as
EMAIL="dev@example.com" FULLNAME="Master Yedi"