6

Problem description and reproduction

In terminal run:

shellcheck -x my_script

Where my_script sources another (partial) script.

I get no error with the -x switch, but if I run it without -x:

shellcheck my_script

I get notification like this one:

. ./functions/my_function

  ^-- SC1091: Not following: ... was not specified as input (see shellcheck -x).

SC1091 on GitHub


My ShellCheck

I'm working with self-compiled ShellCheck located in:

~/.cabal/bin/shellcheck

Goal

I'm working with Visual Studio Code GUI text editor. Is there a way to force the -x switch in there somewhere or other solution?

Vlastimil Burián
  • 27,586
  • 56
  • 179
  • 309

1 Answers1

12

Inside VS Code, the ShellCheck extension can be configured with optional arguments; from the settings, either in its GUI directly or by editing settings.json.

ShellCheck Custom Args setting in GUI directly

ShellCheck Custom Args setting.json file

So, you may open settings.json, and add something like:

"shellcheck.customArgs": ["-x"],

(Thanks to muru for the hint.)

There are a couple of ways to use -x regardless of the tool invoking shellcheck:

  • you can set default options in SHELLCHECK_OPTS:

      export SHELLCHECK_OPTS='-x'
    
  • you could replace your binary:

      mv ~/.cabal/bin/shellcheck{,-real}
      printf '#!/bin/sh\nshellcheck-real -x "$@"\n' > ~/.cabal/bin/shellcheck
      chmod 755 ~/.cabal/bin/shellcheck
    
Vlastimil Burián
  • 27,586
  • 56
  • 179
  • 309
Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164