As software engineers, we always strive to follow best practices when developing our projects. By that I mean, with each code commit or pull request we like to run automated checks to ensure the quality or security of our code.
But occasionally, some Bash or shell script with code which has been copy-pasted from the internet finds its way into the project – and these scripts inevitably behave unexpectedly when tested across a range of different scenarios.
That’s where ShellCheck comes into its own – and it could potentially save you a heck of a lot of time in your day-to-day software development.
What is ShellCheck ?
ShellCheck is a Bash or sh script linting tool that can be used to detect the quality violations – and ensure that scripts follow the best practices.
Here are some of the main uses of ShellCheck:
It detects various types of inaccurate quoting
It can identify many incorrect conditional statements
It recognizes the misuse of commands
It detects syntax errors
It make suggestions for improving the robustness of the script
In this blog, we introduced the ShellCheck linting tool for Bash and shell scripts. We hope this guide helps you write shell scripts which conform to best practices and have consistent syntax – so they’re always easy to maintain, robust and portable. That way, if anyone mentions Ghost in the Shell when you’re coding you can happily refer them to Manga.