Bird
0
0

What is wrong with this script snippet?

medium📝 Debug Q7 of 15
Bash Scripting - Error Handling
What is wrong with this script snippet?
set pipefail
false | true
AThe pipefail option is enabled incorrectly.
BThe pipeline commands are invalid.
CThe script is missing a shebang line.
DThere is no error; the script is correct.
Step-by-Step Solution
Solution:
  1. Step 1: Check how pipefail is enabled

    The command set pipefail is invalid; correct syntax is set -o pipefail.
  2. Step 2: Validate pipeline commands

    false and true are valid commands.
  3. Final Answer:

    The pipefail option is enabled incorrectly. -> Option A
  4. Quick Check:

    Enable pipefail with 'set -o pipefail' only [OK]
Quick Trick: Use 'set -o pipefail' not 'set pipefail' [OK]
Common Mistakes:
MISTAKES
  • Omitting '-o' when enabling pipefail
  • Assuming 'set pipefail' works
  • Ignoring syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes