If you’ve been writing shell scripts, or if you’re new to writing scripts, you may not know of ShellCheck – and you that can install ShellCheck for use locally. This means you don’t need to go online to check your shell scripts, saving you time and effort – as well as being available offline.
If you don’t already know of ShellCheck, march your ass over there right this minute! It’s one of the greatest tools on the internet. If you’ve already read the whole linked page, you can pretty much skip this entire article! After all, it tells you how to install ShellCheck over there – and I’ll be duplicating a lot of that here.
Why am I duplicating it? Because so few people seem aware of it. So few people know this tool exists, even for online use. Time and time again, I see scripting questions that can be debugged/resolved using this wonderful ShellCheck tool.
So, like many of the articles on this site, it’s here so that we can link to this article and not have to repeat ourselves time and time again. Like much of the site, it’s meant to save time and to avoid duplicating effort!
There are other ways to use ShellCheck, such as directly in your editor. This article will not be covering those other ways, I’m simply going to tell you how to install it and use it from your terminal.
Install ShellCheck For Local Use:
Like so many of these things, you need to start with an open terminal. To do so, use your keyboard – just press
Once you have the terminal open, you can install ShellCheck. It’s available in most default repositories, so you shouldn’t have any issues installing it.
One of those ought to work. If not, follow the link in the second paragraph, poke around, and you’ll see that you can likely get ShellCheck installed with little or no difficulty. Worst case, you can grab the binaries and install it manually.
Using ShellCheck is even easier. You just use ‘shellcheck’ and then the path to the script. So, it’d look something like one of the following:
It’s really that easy. ShellCheck isn’t perfect and it doesn’t recognize every error, but it’ll catch a ton of beginner mistakes and typos. It’ll catch syntax issues and punctuation mistakes. It’s pretty handy and is absolutely a great tool for anyone that does any scripting at all.
And there’s another article! This one will help you install ShellCheck, a fantastic tool for people who need to check their scripts. It’s right there in the application’s title! Really, more people need to be aware that it exists, and hopefully this article does a little something to help raise awareness.