ShellCheck Support
ShellCheck, a powerful tool to analyze shell scripts, is bundled with BashSupport Pro.
Binaries of ShellCheck 0.10.0 are shipped with the plugin for macOS, Windows, and Linux. Please refer to all supported ShellCheck codes for a complete list of all supported codes of ShellCheck.
Error Highlighting
BashSupport Pro integrates ShellCheck’s warnings and error messages into the editor.
The fixes returned by ShellCheck are shown as quick fixes in the user interface. BashSupport Pro adds some additional quick fixes for a few common ShellCheck warnings.
ShellCheck Directives
ShellCheck supports # shellcheck
comments to configure ShellCheck and to control the warnings shown for a file.
Tooltips
BashSupport Pro displays tooltips on the SC–codes of directives so that you don’t have to learn or search for the codes.
Directive shellcheck disable=
The ShellCheck disable directive is automatically inserted by BashSupport Pro to suppress ShellCheck messages.
It works as usual:
- Press Alt → Enter on a warning to see quickfixes and intentions
- Choose Suppress for statement in the context menu of the warning you want to suppress. Depending on the context, you can also choose Suppress for function or Suppress for file.
Multiple disable= directives for the same line are separated by a comma (,
).
|
|
Directive shellcheck source=
BashSupport Pro supports ShellCheck’s source
directive. This directive is useful for filenames, which are not static.
|
|
Here, ../other.sh
is a static value, but "$(dirname "${BASH_SOURCE[0]}")/other.sh"
is not.
ShellCheck and BashSupport Pro only understand static values.
Now you can use the # shellcheck source=
directive to define the static location:
|
|
BashSupport Pro assumes that the source
path is relative to the current file.
By default, ShellCheck uses the directory where it’s executed as root for source
paths. Use the source-path directive or execute shellcheck -P ...
if this is a problem in your setup.
- Go to Declaration
- You can navigate to the source files by ctrl → click or by using the Navigate → Go to Declaration action.
- Rename
- The
source=
path is updated when you rename the referenced file. It’s also updated when you move the file containing the source directive.
Settings
BashSupport Pro bundles ShellCheck binaries for macOS, Linux and Windows. If you want to use a locally installed version of ShellCheck, then you can set your own path at Settings… → Languages & Frameworks → BashSupport Pro. Please make sure, that it points to ShellCheck 0.10.0 or later.