Conditional assignment based on environment variable
You could also use a case/switch in bash
to do this:
case "$MYAPP_ENV" in
PROD) SERVER_LOGIN="[email protected]" ;;
*) SERVER_LOGIN="[email protected]" ;;
esac
Or this method:
[ "$MYAPP_ENV" = PROD ] &&
[email protected] ||
[email protected]
Try:
[ condition ] && var=value_when_true || var=value_when_false
If your assignment is numeric, you can use bash
ternary operation:
(( assign_condition ? value_when_true : value_when_false ))
You can use the &&
and ||
operators
[ "$MYAPP_ENV" == "PROD" ] && [email protected] || [email protected]