Error Detection
Detect errors early during execution.
Shell Script · Lesson
Shell Scripting · Lesson 18
components/shell/ShellLessons.jsDebugging is the process of finding and fixing errors in a script. Shell provides built-in tools to help trace execution and handle failures.
Detect errors early during execution.
Prevent scripts from crashing silently.
Improve script reliability and safety.
set -x – Print commands before executionset -e – Exit on errorset -u – Treat unset variables as errorstrap – Catch signals and cleanupPrints each command before executing it.
Stops script execution when a command fails.
Treats unset variables as errors.
Execute commands when script exits or receives signals.
Next lesson: Logging & Redirection