I see a lot of shell scripts (for example, this one) checking for a variable's presence/absence like:
[ -n "${VAR-}" ]
As far as I can tell, using the ${VAR-fallback} form without providing a fallback serves no purpose when checking for variable presence/absence (-n or -z). The same goes for ${VAR:-fallback}. For example, with an unset variable,
unset VAR
[ -z "$VAR" ] &&
[ -z "${VAR-}" ] &&
[ -z "${VAR:-}" ] &&
echo True # => True
and with a null variable
VAR=
[ -z "$VAR" ] &&
[ -z "${VAR-}" ] &&
[ -z "${VAR:-}" ] &&
echo True # => True
But I see it in enough places that I have to ask, am I missing something? Is it just a misunderstanding that results in misuse, or is there actually a reason to do it?