Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Analyze shell scripts with ShellCheck

📅 2021-Mar-02 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ bash, shellcheck ⬩ 📚 Archive

ShellCheck is a godsend for people like me who are not Bash/sh experts, but still need to write and maintains scripts of good quality. It analyzes your script against a series of built-in checks and offers suggestions for improving the script.

Here is the best part of using this tool in your daily workflow: I find it to be the most practical way to learn good quality shell programming practices. This is way better than reading the ginormous Bash manual anyday.

Hook this tool to your CI/CD or to your git pre-commit hooks to get scripts in your codebase automatically checked for quality.

$ sudo apt install shellcheck

$ shellcheck myscript.sh

Tried with: ShellCheck 0.4.6 and Ubuntu 18.04