Recall & Review
beginner
What is a silent failure in bash scripting?
A silent failure happens when a script encounters an error but does not show any message or stop. This makes it hard to know something went wrong.
Click to reveal answer
beginner
How does error handling help prevent silent failures?
Error handling shows messages or stops the script when something goes wrong. This helps you notice and fix problems quickly.
Click to reveal answer
beginner
What bash command can you use to stop a script on any error?
Use
set -e. It makes the script stop immediately if any command fails.Click to reveal answer
intermediate
Why is it important to check command exit status in bash?
Checking exit status tells you if a command worked or failed. Without checking, errors can go unnoticed and cause silent failures.
Click to reveal answer
intermediate
Give an example of a simple error handling method in bash.
You can check a command's exit code with
if like this:<br>if ! cp file1.txt backup/; then echo "Copy failed!" exit 1 fi
Click to reveal answer
What does
set -e do in a bash script?✗ Incorrect
set -e makes the script stop immediately when a command returns an error, preventing silent failures.Why should you check the exit status of commands in bash?
✗ Incorrect
Checking exit status helps detect errors so you can handle them properly.
What is a silent failure?
✗ Incorrect
Silent failure means the script fails but does not tell you, making it hard to find the problem.
Which of these helps prevent silent failures?
✗ Incorrect
Error handling shows when something goes wrong, so you can fix it.
What happens if you don't handle errors in a bash script?
✗ Incorrect
Without error handling, errors can happen silently and cause bigger problems later.
Explain why error handling is important to prevent silent failures in bash scripts.
Think about what happens if a command fails but the script keeps running quietly.
You got /4 concepts.
Describe simple ways to add error handling in a bash script.
Consider commands that stop the script or show messages when something goes wrong.
You got /4 concepts.