Security Engineering
A Bash cleanup script deletes the contents of a directory whose path is held in a variable that might never be set. Which change best stops the script from running with that variable unset?
Show the answer
Correct answerB. Enable nounset so unset variables raise an error
AWhy not this: chmod 700 limits who can execute the script but not how it handles variables.
BWhy this is right: nounset (set -u) makes Bash abort when an unset variable is expanded.
CWhy not this: try/except is Python syntax and does not exist in Bash.
DWhy not this: Execution policy is a PowerShell setting and does not apply to Bash.
Enabling nounset (set -u) makes Bash treat an unset variable as an error and stop, so the cleanup cannot run against an empty path. Restricting file mode only controls who can run the script and does nothing about its variable handling.