Created
February 10, 2021 19:50
-
-
Save adduc/fd7b3ee1a1a5c43af2740cf4d0657f87 to your computer and use it in GitHub Desktop.
Bash: Load config without overwriting existing env variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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