Linux › Section K · Shell scripts › Topic K.2
Special variables and exit codes
A script becomes a real tool when it can take arguments and report whether it worked. The shell's special variables deliver the arguments, and exit codes carry success or failure back to whoever ran the script, which is also the key to finding out why a script went wrong.
In this topic
- Variables the shell fills in for you
- Positional parameters and shift
- Count, name and process ID
- All the arguments: "$@" and "$*"
- Exit codes and $?
- When non-zero is not an error
- Worked example: refusing bad arguments
- Worked example: tracing with set -x
- set -e, set -u and pipefail
- ShellCheck
- Common mistakes to avoid
- Key takeaways
This topic is part of Wuanberri Pro. Checking your access…
