Bash: Import variables from a .env file by tokudantokudan (Random texts)
This sets and exports all variables set in a .env file that can also be used by systemd to setup environment variables. Read and export ...

Yw, yes set -a / set +a before and after sourcing a file in bash makes this easier. I found out when I needed this to quickly source an env file used by a script that is launched and configured by systemd like this:

EnvironmentFile=%h/.config/foo.env

Sometimes I’ve to run this script manually so I do this to source the same config:

set -a
. /path/to/.config/foo.env
set +a
foo --bar