Quick Linux Tip #128:
Question: How do I lint my bash scripts for bugs and security issues?
Try: shellcheck /opt/scripts/backup.sh
Info: Static analysis tool that catches common bugs, security flaws, and style issues in shell scripts.
Examples:
- $
shellcheck -s bash *.sh# Force the shell dialect to bash explicitly - $
shellcheck -f gcc script.sh# Generate compiler-style output tailored for text editors - $
find . -name '*.sh' -exec shellcheck {} +# Recursively lint all shell scripts across a directory
Note: Install via sudo apt install shellcheck. Specific rule numbers (e.g., SC2086) make it easy to look up solutions online. Integrate into CI/CD pipelines to catch bugs before code reaches production.
Leave a Reply