Skip to content

Instantly share code, notes, and snippets.

@adduc
Created February 10, 2021 19:50
Show Gist options
  • Save adduc/fd7b3ee1a1a5c43af2740cf4d0657f87 to your computer and use it in GitHub Desktop.
Save adduc/fd7b3ee1a1a5c43af2740cf4d0657f87 to your computer and use it in GitHub Desktop.
Bash: Load config without overwriting existing env variables
# export current environment
EXISTING_ENV=$(export -p)
# import variables from file
. config.env
# import previous environment
source <(echo "$EXISTING_ENV")
# At this point, only variables from config.env that did
# not exist in the environment will have been declared.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment