Question
In linux, how do you guard against the default risky shell behavior of treating non-existing variables as empty values (e.g. if you try to reference undefined var TEXT, by $TEXT in script, value is empty string instead of causing explicit error, how do you get shell to spit out explicit error)? Answer set -u ^^ use the set built-in command, at top of script. ^^^ note the u stands for unset (i.e. you are enabling guarding against unset variables) Question In linux, how do you guard against the default risky shell behavior of treating non-existing variables as empty values (e.g. if you try to reference undefined var TEXT, by$TEXT in script, value is empty string instead of causing explicit error, how do you get shell to spit out explicit error)?
?

Question
In linux, how do you guard against the default risky shell behavior of treating non-existing variables as empty values (e.g. if you try to reference undefined var TEXT, by \$TEXT in script, value is empty string instead of causing explicit error, how do you get shell to spit out explicit error)?

set -u

^^ use the set built-in command, at top of script.

^^^ note the u stands for unset (i.e. you are enabling guarding against unset variables)

If you want to change selection, open document below and click on "Move attachment"

ur shell. This option is enabled by default. set -n Read commands without executing them. This command is useful for syntax checking. set -o posix Comply exactly with the POSIX 1003.2 standard. <span>set -u Report an error when trying to reference a variable that is unset. Usually bash just fills in an empty string. set -v Print each line of script as it is executed. set -x Display each co

#### Summary

status measured difficulty not learned 37% [default] 0

No repetitions