On this page
Key takeaways
- ShellCheck is the default static analyzer for Bash and POSIX shell, and it flags quoting and portability problems.
- shfmt formats shell code so style questions stop showing up in review.
- Shells like Bash, Zsh, Fish, PowerShell, and Nushell ship their own syntax checks, but they are not full linters.
- ESLint is useful when shell scripts sit next to JavaScript tooling and you want one lint workflow.
What shell script linters are for
A shell script linter reads your script without running it and reports patterns that tend to break: unquoted variables, word splitting, globbing surprises, non-portable flags, and risky constructs. Static analysis tools go further by parsing the script into a syntax tree, which lets them check structure and style rather than just matching text.
You need one when scripts are shared, reviewed, or run in CI. A single missing quote can delete the wrong files or pass the wrong arguments. If you only write one-off commands at an interactive prompt, a linter adds little. The value appears when a script has to survive a second reader or a different shell.
Quick comparison
| Tool | Best for | Starting price | Free plan |
|---|---|---|---|
| ShellCheck | Finding real bugs in shell scripts | Not included | Not included |
| shfmt | Consistent shell formatting | Not included | Not included |
| Bash | Running scripts with built-in syntax checks | Not included | Not included |
| Zsh | Interactive work and script syntax checking | Not included | Not included |
| Fish | Readable interactive shell scripting | Not included | Not included |
| PowerShell | Object-based scripting with parser checks | Not included | Not included |
| Nushell | Structured data pipelines in a shell | Not included | Not included |
| ESLint | Linting shell-adjacent JavaScript projects | Not included | Not included |
The best shell script linters
1. ShellCheck
- Official site: https://www.shellcheck.net
- Best for: Finding quoting bugs and portability issues
- Starting price: Not included
- Free plan: Not included
- Pros: Explains each warning with a link to a detailed wiki entry; understands Bash, sh, dash, and ksh dialects
- Cons: Reports style opinions alongside real bugs; some checks need suppression comments in legacy scripts
ShellCheck is a static analysis tool for shell scripts. It parses your script and reports problems such as unquoted expansions, incorrect test syntax, useless commands, and constructs that behave differently across shells. Each message carries a code and a short explanation, so you can look up why the pattern is risky. It runs as a command line tool and integrates with many editors and CI systems.
It fits teams that maintain Bash or POSIX shell scripts and want defects caught before runtime.
2. shfmt
- Official site: https://github.com/mvdan/sh
- Best for: Consistent shell formatting
- Starting price: Not included
- Free plan: Not included
- Pros: Formats shell scripts with configurable indentation and redirect style; can also parse and print the syntax tree
- Cons: Does not detect logic bugs; formatting choices can differ from an existing codebase
shfmt is a formatter and parser for shell. It reads Bash, POSIX shell, and related dialects, then prints the script with consistent indentation, spacing, and line breaks. Because it works from a syntax tree rather than text patterns, it handles nested constructs and here documents reliably. You can run it in check mode to fail a build when formatting drifts.
Use it when review comments keep circling back to whitespace and brace placement. It differs from ShellCheck in purpose: shfmt changes layout, it does not judge whether a test is correct.
3. Bash
- Official site: https://savannah.gnu.org/projects/bash
- Best for: Running scripts with built-in syntax checks
- Starting price: Not included
- Free plan: Not included
- Pros: Ships on most Linux and macOS systems; supports a no-execute parse mode for syntax checking
- Cons: Not a static analyzer for style or portability; behavior differs from POSIX sh in places
Bash is the shell most scripts target. It offers a no-execute mode that parses a script and reports syntax errors without running any command, which is a cheap first gate in CI. It also supports strict mode options that turn unset variables and failed commands into visible failures, catching problems earlier at runtime.
It fits anyone writing scripts for Linux servers or macOS workstations. It is not a linter, so it will not warn about an unquoted variable that happens to work today.
4. Zsh
- Official site: https://www.zsh.org
- Best for: Interactive work and script syntax checking
- Starting price: Not included
- Free plan: Not included
- Pros: Strong interactive features with a large completion system; can parse scripts without executing them
- Cons: Script dialect differs from Bash in important ways; not a static analysis tool
Zsh is an interactive shell with scripting support. It offers a no-execute parse mode similar to Bash, so you can validate syntax before running a script. Its completion and prompt features make it a common daily driver for developers who spend hours in a terminal.
Choose it if your team already works in Zsh and wants scripts that match that environment. It differs from Bash in expansion and array behavior, so a script written for one may not run in the other. The limit is clear: it validates syntax, not quoting or portability.
5. Fish
- Official site: https://fishshell.com
- Best for: Readable interactive shell scripting
- Starting price: Not included
- Free plan: Not included
- Pros: Clear syntax with built-in help and autosuggestions; ships a syntax checker for its own scripts
- Cons: Not POSIX compatible, so most existing shell scripts will not run unchanged; limited use for Bash linting
Fish is a shell designed for interactive use, with a syntax that avoids many quoting traps found in older shells. It includes a syntax check mode for its own script files, which helps before you wire a script into automation. Autosuggestions and inline help make it approachable for people new to the terminal.
It fits developers who want a friendlier interactive shell and are willing to write Fish-specific scripts. It is a poor fit if your production scripts must run under sh or Bash, because the dialects are not compatible.
6. PowerShell
- Official site: https://learn.microsoft.com/en-us/powershell
- Best for: Object-based scripting with parser checks
- Starting price: Not included
- Free plan: Not included
- Pros: Cross-platform scripting with structured objects instead of plain text; includes a parser that reports syntax errors
- Cons: Different language and idioms from Bash; not a tool for checking existing shell scripts
PowerShell is a scripting environment built around objects rather than text streams. It runs on Windows, Linux, and macOS, and it exposes a parser that can report syntax errors in a script without executing it. That makes it useful as a pre-run check in automation pipelines.
It fits teams that script across platforms and prefer structured data over string parsing. It differs from the shell linters here because it checks PowerShell syntax, not Bash. The limit: if your codebase is Bash, PowerShell will not help you clean it up.
7. Nushell
- Official site: https://www.nushell.sh
- Best for: Structured data pipelines in a shell
- Starting price: Not included
- Free plan: Not included
- Pros: Treats command output as structured tables; includes a parser check for its own scripts
- Cons: Small ecosystem compared with Bash; not a linter for existing shell scripts
Nushell is a shell that models data as tables and records, so filtering and sorting output does not depend on text tools. It provides a parse check for its own scripts, which catches syntax problems before execution. Pipelines read more like data queries than string manipulation.
It fits developers who work with structured output from APIs and command line tools and want fewer parsing bugs. It is not a drop-in replacement for Bash scripts, and it will not analyze them. Consider it for new tooling where data shape matters more than POSIX compatibility.
8. ESLint
- Official site: https://eslint.org
- Best for: Linting shell-adjacent JavaScript projects
- Starting price: Not included
- Free plan: Not included
- Pros: Pluggable rule system with custom rules; widely used in JavaScript and TypeScript projects
- Cons: Does not parse shell scripts; requires plugins or wrappers to touch shell files
ESLint is a static analysis tool for JavaScript and TypeScript. It parses code into a syntax tree and applies configurable rules, and you can write custom rules for project conventions. It runs in editors and CI, which makes it a familiar gate for web teams.
It fits repositories where shell scripts live beside Node tooling and you want one lint command. It does not understand shell syntax on its own, so shell coverage depends on added plugins or wrapper scripts. The limit: do not expect it to replace a dedicated shell analyzer.
How to choose
Start with the language your scripts actually target. If they run under sh or Bash, pick a shell-specific analyzer first, then add a formatter so style stops consuming review time.
- Stack: match the tool to your shell dialect, since Bash, Zsh, Fish, PowerShell, and Nushell are not interchangeable.
- Team size: shared scripts need an agreed rule set and suppression policy, not just a tool.
- Hosting and CI: confirm the tool runs as a command line step in your pipeline before you commit to it.
- Learning curve: analyzers that explain each warning are easier to adopt than ones that only print codes.
- Lock-in: prefer tools that read plain script files and need no runtime changes.
- Support: check that documentation covers the constructs your scripts use.
How we chose
Tools were selected from official product pages and documentation, based on fit for shell script review, active maintenance signals visible on those pages, and clear use cases for developers. No documentation review was performed, and no performance claims are made here. The list mixes dedicated linters and formatters with shells that offer their own parse checks, so you can see where each one helps and where it stops.
FAQ
What is the difference between a shell script linter and a formatter?
A linter reports risky patterns such as unquoted variables and non-portable flags. A formatter rewrites layout, including indentation and spacing. Most teams run both, because each solves a different review problem.
Can a linter catch every quoting bug?
No. Static analysis catches many common patterns, but it cannot know your intent, and some warnings are false positives. Treat findings as prompts to review the code, not as automatic proof of a bug.
Do I need a linter for short scripts?
Short scripts benefit least, especially one-off commands at a prompt. Add a linter once a script is shared, reviewed, or run in automation, where a quoting mistake can affect other people or files.
Does a syntax check replace static analysis?
No. A parse check only confirms the script is syntactically valid. It will not flag an unquoted variable or a construct that behaves differently across shells, which is where a dedicated analyzer adds value.