Skip to content

Instantly share code, notes, and snippets.

@minhd
Created July 16, 2018 05:11
Show Gist options
  • Save minhd/884e1079d396ccafc7ceb816da0ca031 to your computer and use it in GitHub Desktop.
Save minhd/884e1079d396ccafc7ceb816da0ca031 to your computer and use it in GitHub Desktop.
Bash script defaul variable #bash
if [[ -z "${DEPLOY_ENV}" ]]; then
MY_SCRIPT_VARIABLE="Some default value because DEPLOY_ENV is undefined"
else
MY_SCRIPT_VARIABLE="${DEPLOY_ENV}"
fi
# or using a short-hand version
[[ -z "${DEPLOY_ENV}" ]] && MyVar='default' || MyVar="${DEPLOY_ENV}"
# or even shorter use
MyVar="${DEPLOY_ENV:-default_value}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment