When you source
the file, the assignments will be set but the variables are not exported unless the allexport
option has been set. If you want all the variables to be exported, it is much simpler to use allexport
and source
the file than it is to read the file and use export
explicitly. In other words, you should do:
set -a
. file.txt
(I prefer .
because it is more portable than source
, but source
works just fine in bash
.)
Note that exporting a variable does not make it an environment variable. It just makes it an environment variable in any subshell.