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

Leave a Reply

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)