I have a file .env containing environment variables, e.g.:
TZ=UTC
NODE_ENV=development
Then, in my Bash scripts, I use:
set -o allexport; source .env; set +o allexport
This loads all the environment variables from .env.
However, if I manually pass environment variables to the script, they get overwritten by source. E.g. if I run NODE_ENV=production ./script.sh, I'd like it to keep NODE_ENV=production instead of using NODE_ENV=development from .env. How could I do this?
I'm using Ubuntu 20