ShellCheck
A linter for shell scripts that reports quoting mistakes, portability problems and common bugs, each with a numbered code.
In more detail
Each finding names the file, line, severity level and a code, and every code has a wiki page explaining the fix. Levels run error, warning, info and style, and --severity=warning hides the lower two. With --shell=sh, or a sh shebang, it also reports features that plain sh lacks.
Examples
shellcheck script.shshellcheck --severity=warning script.shshellcheck release.shRelated terms
- linter — A tool that reads code or configuration without running it and flags likely mistakes and style problems.
- SC2086 — The ShellCheck warning for an unquoted variable expansion, which may be split into several words or expanded as a glob.
- ShellCheck directive — A comment such as # shellcheck disable=SC2086 that tells ShellCheck to skip one finding on the next line.
- bashism — A bash-only feature, such as [[ ]], arrays, (( )) or process substitution, used in a script that claims to be POSIX sh.
- shell script — A text file of shell commands that runs them in order, top to bottom, as if you had typed them one by one.
Taught in
- Redirection: Truncate, Append, Both Streams — Bash Scripting & Command Line Automation
- Shell Variables, The Environment And export — Bash Scripting & Command Line Automation
- Command Substitution And Subshells — Bash Scripting & Command Line Automation
- Arguments: Dollar One, Dollar At, shift — Bash Scripting & Command Line Automation
- set -e, set -u And pipefail: Promises And Traps — Bash Scripting & Command Line Automation
- ShellCheck — Bash Scripting & Command Line Automation
- POSIX sh Versus Bash — Bash Scripting & Command Line Automation
- eval, And What To Use Instead — Bash Scripting & Command Line Automation
- find And xargs — Bash Scripting & Command Line Automation
- Workflows, Jobs, Steps, and Actions — Continuous Integration & Continuous Delivery Pipelines
- Minimal Base Images: Less To Attack — Certified Kubernetes Security Specialist (CKS) Exam Prep
- The Cleanup That Emptied The Wrong Directory: Shell Scripts Under Exam Conditions — CompTIA Linux+ (XK0-006) Exam Prep
- The Assistant Was Confident: Reviewing AI-Generated Code, Prompts And Data — CompTIA Linux+ (XK0-006) Exam Prep