0

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?

Saulo
  • 499
  • 1
  • 4
  • 16
  • https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash https://stackoverflow.com/a/17538964/9072753 – KamilCuk Mar 18 '23 at 08:54

0 Answers0