Skip to content
Justice Tech School

Strict Mode and Safety

set -e exits on errors, set -u fails on unset variables and set -o pipefail catches failures inside pipes. Quote everything and use trap for cleanup.

Example
set -euo pipefail
name=${1:-world}
trap 'echo cleanup' EXIT
echo "hello $name"

Result

hello world
cleanup

Exercise

Exit on any error.

set e

Quiz Test

What does set -u do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.