I always start my scripts with set -u
to prevent myself from using undeclared variables which is, most of the cases, an typo.
However, in order to verify whether a system variables is declared (such as EDITOR) or not I need to set +u
, verify, and then set -u
again. Otherwise I get the unbound variable
error.
Is there any other way to deal with this situation that doesn't involve enabling/disabling unbounded variables?