ShellCheck – A Free Utility To Find Bugs In Your Shell Scripts

You just wrote a script and wanted to check if there are any bugs in it, but you don’t know how? No worries! Now, you can easily find bugs in your shell scripts using ShellCheck. ShellCheck is a static analysis tool for shell scripts. It will tell you immediately if there is any errors in your shell scripts instantly. It is written in Haskell language and freely distributed under GPLv3.

You don’t need any expert’s help to rectify bugs in your scripts. Just open ShellCheck, paste your script and boom! You can use ShellCheck either online or offline. In this brief tutorial, I will show you both!

ShellCheck on Web

You can check the scripts on online at any by visiting the ShellCheck website.

Open up your web browser and go to the following link.

Paste your shell script in it for instant feedback.

Sample output:

Note: I didn’t write the script used in this example. I just found it online to test ShellCheck.

Alternatively, you can install it on your Linux box and test your script at anytime offline.

Install ShellCheck On Linux

ShellCheck is packaged for most Linux operating systems. You can easily install it using your distribution’s package manager as shown below.

On Arch Linux and its derivatives:

$ sudo pacman -S shellcheck

On Debian, Ubuntu, Linux Mint, run the following command to install it:

As you see in the above output, ShellCheck indicates the suggestions at line 1 and line 6. Please be mindful that ShellCheck won’t fix the errors in the scripts automatically. Instead, it will give warnings and suggestions for your shell scripts. This utility could be useful for budding script writers who wants to learn Shell scripting. Just write a script, copy/paste the code in ShellCheck and make it error-free in minutes. Give it a try. You won’t be disappointed.

And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned!