Created
July 16, 2018 05:11
-
-
Save minhd/884e1079d396ccafc7ceb816da0ca031 to your computer and use it in GitHub Desktop.
Bash script defaul variable #bash
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
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