Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



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)?
Answer
?

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)

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

20. Advanced Shell Scripting
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

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.