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?

0

1 Answer 1

14

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
    
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .