Bird
0
0

Why might set -e not cause a script to exit on some failing commands?

hard🧠 Conceptual Q10 of 15
Bash Scripting - Error Handling
Why might set -e not cause a script to exit on some failing commands?
ABecause errors in conditional tests or &&/|| chains are ignored by set -e.
BBecause set -e only works on commands with exit code 0.
CBecause set -e disables error checking for all commands.
DBecause set -e requires explicit error handling to work.
Step-by-Step Solution
Solution:
  1. Step 1: Understand exceptions to set -e behavior

    set -e ignores errors in commands used in conditional tests, like in if statements or &&/|| chains.
  2. Step 2: Explain why script may continue

    These exceptions allow scripts to handle errors gracefully without exiting immediately.
  3. Final Answer:

    Because errors in conditional tests or &&/|| chains are ignored by set -e. -> Option A
  4. Quick Check:

    set -e ignores errors in conditionals and chains [OK]
Quick Trick: set -e ignores errors in conditionals and &&/|| chains [OK]
Common Mistakes:
MISTAKES
  • Thinking set -e always exits on any error
  • Believing set -e disables error checking
  • Assuming explicit error handling is required

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes