By default Bash is forgiving: if a command fails, the script carries on, an unset variable quietly becomes an empty string, and a failure early in a pipeline is ignored. That tolerance turns small mistakes into big damage, such as a script that runs rm -rf "$dir/"* when dir was never set. Defensive scripting habits prevent this, and Linux+ expects you to recognize them in code and choose the right one for a described problem.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 7 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.