Unlike most other popular scripting languages, Bash has few style-checking utilities. The best one, I think, is ShellCheck – a very cool and useful utility that can greatly  enhance robustness of your scripts. Like that time a Windows user dropped a file with a line break in the name into an SMB share and my backup script exploded all over that filesystem. I could have avoided that unfortunate experience if I had shellcheck to tell me to use read -r and to double-quote just about everything that can be double-quoted.

You can try shellcheck on their site or install it on your local box. Installation is pretty straight-forward for some platforms, but CentOS/RHEL require some finagling. In a nutshell, you need to install Dev tools group and Haskell compiler:

Example:

 

Leave A Reply

Please enter your comment!
Please enter your name here