bash scripts - set -o nounset / -n versus -v

The style…

[ -n "$VARNAME" ] || VARNAME="xxx"

in Whonix source code served well but is not the most ideal. The following would be a bit better.

[[ -v VARNAME ]] || VARNAME="xxx"

That is because then scripts could be improved and use:

set -o nounset
1 Like