How to install ShellCheck on FreeBSD – A shell script static analysis tool

ShellCheck is a static analysis tool for shell scripts that helps to identify and fix common issues and errors. You can install ShellCheck on FreeBSD using the package manager pkg.

  1. First, ensure that the package manager is updated by running the command:
pkg update
  1. Next, install ShellCheck by running the command:
pkg install shellcheck
  1. Once the installation is complete, you can check the version of ShellCheck installed by running the command:
shellcheck --version
  1. To use ShellCheck, you can pass the path of a shell script as an argument to the command. For example, to check the script located at /usr/local/bin/myscript.sh:
shellcheck /usr/local/bin/myscript.sh
  1. You can also check the entire directory using the command:
shellcheck /usr/local/bin/*

It is important to note that ShellCheck may show some false positive and some errors may not be critical, so it’s important to review the output and apply the suggestions accordingly. Additionally, to use ShellCheck on the scripts that use a specific shell, you can use the –shell option and specify the shell (bash, ksh, sh etc.).

Leave a Comment