Default value for bash vars

The situation: there’s a script that runs daily and usually exports yesterdays data. In some cases I would want to manually set it to a different date using a shell param or env variable (because it runs in a gitlab-runner e.g.).

In perl this would be done using $var = ($var ? $var : "default"); and it turns out that the syntax is pretty similar in bash scripting:

This is how our var is declared without a default values:
YESTERDAY=$(date +%Y-%m-%d --date="1 day ago")

And this is how it’s done if the value may be overriden via shell (script.sh 2022-11-22):
YESTERDAY=${1:-$(date +%Y-%m-%d --date="1 day ago")}
…or via an env var (YESTERDAY="2022-11-22" script.sh):
YESTERDAY=${YESTERDAY:-$(date +%Y-%m-%d --date="1 day ago")}