The static analysis utility for ShellCheck 0.9 scripts has now been released

shell check

ShellCheck is an open source static analysis tool that automatically finds errors in your shell scripts.

The availability of the new version of ShellCheck 0.9, a static analyzer for shell scripts which is an excellent tool for code analysis.

For those unaware of Shellcheck they should know that this is a static analysis tool showing warnings and hints about bad codes in bash/sh shell scripts.

It can be used in various ways: from the web by pasting your shell script into an online editor or alternatively, it can be to install it on your system and run it from the terminal, integrate it with your text editor, as well as your compilation or suites test.

There are three things that ShellCheck does primarily:

  • Point out and explain typical beginner syntax problems that cause a shell to give cryptic error messages.
  • Point out and explain typical intermediate-level semantic problems that cause a shell to behave strangely.
  • It also points out subtle warnings, which can cause an otherwise working advanced script to fail in future circumstances.

Additionally, it supports outputting recommendations to improve code styling, eliminate portability issues, and improve script reliability. For example, instead of "echo $[1+2]" it will be suggested to use the syntax "$((...))", the construct 'rm -rf "$STEAMROOT/"*' will be marked as unsafe and capable of removing the root directory if the variable is not filled $STEAMROOT and using "echo {1..10}" will be highlighted as incompatible with dash and sh.

Main new features of ShellCheck 0.9

The new version of ShellCheck 0.9 arrives with few changes, of which we can highlight the addition of a recommendation to remove ((..))inarray[((idx))]=val, as well as that added a warning about unavailable commands.

One of the other changes that stands out is that a backreference warning was added for 'declare x = 1 y = $x', as well as an added warning if $? is used to issue the return code of echo, printf, [ ], [[ ]], and test.

In addition to this, we can also find that a new recommendation to concatenate double square brackets in arithmetic contexts, as well as the recommendation to eliminate the parentheses in the expression a[(x+1)]=val.

Finally, if you are interested in being able to know more about it, you can consult the details in the following link

How to install ShellCheck on Linux?

If you are interested in being able to obtain this great utility, all you have to do is open a terminal on your system and type one of the following commands, according to the Linux distribution you are using.

Users of Debian, Ubuntu and any other distribution derived from these, they only have to type in the terminal the following command:

sudo apt-get install shellcheck

If they are users of RHEL, CentOS, Fedora or any distribution derived from these, can install with:

sudo dnf install shellcheck

For users of Arch Linux, Antergos, Manjaro and derivatives of Arch Linux, install the utility with:

sudo pacman -S shellcheck

While for those who are openSUSE users, the installation is done with:

sudo zypper in shellcheck

Si use Atom text editor, you can also use ShellCheck within your editor window on the go. They just have to install the atom packages needed for ShellCheck:

apm install linter linter-shellcheck

ShellCheck tIt also supports other editors, such as: Vim, Emacs, Sublime, etc. You can find a complete list In the following link.  

Basic use of ShellCheck

After installing the necessary packages for ShellCheck on your system, They can use them from their terminal, they just have to write the following command:

shellcheck / path / to / file

Where they just have to put the path with the filename of their shell script.

Using ShellCheck online

Also, you can use ShellCheck online without installing anything on your system, so you only have to use your preferred web browser and go to to the following link.

Here they just have to copy the codes from their shell script and it will show the ShellCheck output.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.