Strict, opinionated ShellCheck configurations for all supported shell dialects.
This repository provides production-ready ShellCheck configurations with maximum strictness enabled. Each config is tailored for a specific shell dialect and enables all optional checks for the highest code quality.
| Config File | Shell Dialect | Use Case |
|---|---|---|
| .shellcheckrc.sh | POSIX sh | Maximum portability across all POSIX systems |
| .shellcheckrc.bash | bash | Most common, feature-rich scripting |
| .shellcheckrc.dash | dash | Debian/Ubuntu /bin/sh, lightweight scripts |
| .shellcheckrc.ksh | ksh | KornShell environments |
| .shellcheckrc.busybox | busybox | Embedded systems, Alpine Linux, minimal containers |
All configurations include:
- ✅ All optional checks enabled (
enable=all) - ✅ Maximum strictness (
severity=style) - ✅ External source following (
external-sources=true) - ✅ Source path resolution (
source-path=SCRIPTDIR) - ✅ Clear documentation with comments explaining each setting
- ✅ Consistent structure across all dialects
# For bash scripts (most common)
curl -o .shellcheckrc https://raw.githubusercontent.com/gfmio/config-shellcheck/main/.shellcheckrc.bash
# For POSIX sh (maximum portability)
curl -o .shellcheckrc https://raw.githubusercontent.com/gfmio/config-shellcheck/main/.shellcheckrc.sh
# For dash
curl -o .shellcheckrc https://raw.githubusercontent.com/gfmio/config-shellcheck/main/.shellcheckrc.dash
# For ksh
curl -o .shellcheckrc https://raw.githubusercontent.com/gfmio/config-shellcheck/main/.shellcheckrc.ksh
# For busybox
curl -o .shellcheckrc https://raw.githubusercontent.com/gfmio/config-shellcheck/main/.shellcheckrc.busybox# Clone this repo
git clone https://github.com/gfmio/config-shellcheck.git ~/.config/shellcheck-configs
# Symlink the config you need
ln -s ~/.config/shellcheck-configs/.shellcheckrc.bash .shellcheckrc# No need to copy - reference directly
shellcheck --config-file=/path/to/config-shellcheck/.shellcheckrc.bash script.shOnce installed as .shellcheckrc in your project root:
shellcheck script.shShellCheck will automatically find and use the config file.
You can use a config directly without renaming:
shellcheck --config-file=.shellcheckrc.sh script.shThe configs use severity=style for maximum strictness during development. In CI/CD, you might want to fail only on errors/warnings:
# Fail only on errors
shellcheck -S error script.sh
# Fail on errors and warnings
shellcheck -S warning script.shIf you need to disable certain checks for your project, uncomment and modify the disable= line in your .shellcheckrc:
# Disable specific checks
disable=SC2034,SC2086Or use inline directives in your scripts:
# shellcheck disable=SC2086
echo $varshell=<dialect>- Explicitly sets the shell dialectenable=all- Enables all optional checks including:quote-safe-variables- Enforce quoting even for "safe" variablesrequire-variable-braces- Always use${var}instead of$varcheck-unassigned-uppercase- Catch potential environment variable typosadd-default-case- Require default case in switch statements
external-sources=true- Followssourcestatements to check sourced filessource-path=SCRIPTDIR- Resolves relative source paths from script directoryseverity=style- Reports all issues at any severity level
- Maximum strictness catches potential bugs early
- All optional checks enforce best practices consistently
- External source following ensures modular scripts are fully analyzed
- Style-level reporting helps maintain high code quality standards
- Scripts need to run on any UNIX-like system
- Maximum portability is required
- You want warnings about bashisms
- Target systems may not have bash installed
- Most common choice for Linux systems
- Need arrays, associative arrays, or process substitution
- Using bash-specific features like
[[or(()) - Target systems are known to have bash
- Targeting Debian/Ubuntu systems where
/bin/shis dash - Need fast script execution
- Want POSIX compliance with dash-specific optimizations
- Working in KornShell environments
- Legacy systems or enterprise Unix that standardize on ksh
- Need ksh-specific features
- Embedded systems or IoT devices
- Alpine Linux containers
- Minimal Docker images
- Resource-constrained environments
Add to .git/hooks/pre-commit:
#!/bin/sh
git diff --cached --name-only --diff-filter=ACM | grep '\.sh$' | xargs shellcheckname: ShellCheck
on: [push, pull_request]
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
severity: warningInstall the ShellCheck extension - it will automatically use your .shellcheckrc.
While these configs provide strict defaults, you can customize them for your needs:
- Copy the config to your project
- Modify settings as needed
- Document your changes with comments explaining why
ShellCheck is a static analysis tool for shell scripts that helps you:
- Find and fix bugs in your scripts
- Avoid common pitfalls and gotchas
- Write more portable and robust code
- Follow shell scripting best practices
Learn more: shellcheck.net
ShellCheck supports these dialects only:
- ✅ POSIX sh
- ✅ bash
- ✅ dash
- ✅ ksh
- ✅ busybox
Not supported: zsh, fish (they have different syntax and tooling)
Contributions welcome! Please:
- Explain the rationale for any changes
- Keep configs consistent across dialects
- Update documentation accordingly
- Test with actual ShellCheck usage
- ShellCheck Wiki
- Error Code Reference
- ShellCheck GitHub
- List Optional Checks - Run
shellcheck --list-optional