In the traditional Bourne Shell (sh), if one wants to make sure that, at some point in the script, a variable has been set and at least it has some specific default value, one can use this construct:
: "${VAR:=defaultValue}"
What would be the equivalent for a Zsh script?
Thanks.
Edit: I mean, in case there is a Zsh specific way for doing this. Instead of just doing the true command (:).
Edit2: Rightfully quoting the parameter expansion. See Stéphane Chazelas' answer.
${parameter:=[word]}
syntax is defined by POSIX, is there any reason you don't want to use that? – terdon May 14 '21 at 17:30