I have two configuration files for environment configuration, with content like this:
# First comment
hello='john'
# Second comment
test=3
i.e. a combination of comments, name=value pairs, and white space
Currently I have a reload script which replaces and copies their values to .bash_profile:
cat env.file1 | sed -e 's/#.*$//' -e '/^$/d' -e 's/^/export\ /' >> .bash_profile
cat env.file2 | sed -e 's/#.*$//' -e '/^$/d' -e 's/^/export\ /' >> .bash_profile
I would instead prefer if .bash_profile can instead "source" these two files, somehow performing the transformation in the process. That way it only takes one command (source .bash_profile) instead of two (env-reload && .bash_profile). Also it means the bash_profile can remain unmolested.
How to do this?