Interview practice question
Making a script stop on errors
Cloud & DevOps · Linux and Scripting · Beginner
Your Bash script keeps running after a command fails, causing damage later. How do you make it safer?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- set -euo pipefail.
- -e exit on error, -u undefined vars, pipefail for pipes.
- Check commands explicitly where needed.
- trap for cleanup.
- Quote variables.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.