Skip to content

Instantly share code, notes, and snippets.

@gerritjvv
Created June 23, 2020 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerritjvv/c88177e2b98e4d56265431f7a21d8204 to your computer and use it in GitHub Desktop.
Save gerritjvv/c88177e2b98e4d56265431f7a21d8204 to your computer and use it in GitHub Desktop.
Update variables with a PROD Prefix in bash
# The aim is to support e.g
# URL="dburl" variables and then override at will when PROD_URL is available.
switch_prod.sh
for v in $(env | awk '/PROD_/ {gsub(/PROD_/,""); print $1}'); do
eval "export $v"
done
#call using must use . to source the file, otherwise the environment variables set
# are not seen by the parent process
. ./switch-prod.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment