CircleCI-Public / shellcheck-orb

An orb for ShellCheck, a static analysis tool for shell scripts (https://shellcheck.net) — check all scripts in your repository on every commit
https://circleci.com/developer/orbs/orb/circleci/shellcheck
MIT License
19 stars 26 forks source link

`external_sources` parameter not passed to shellcheck #38

Closed timobrembeck closed 3 years ago

timobrembeck commented 3 years ago

Orb version: 2.2.2

What happened:

The parameter external_sources in both the definition of the check command as well as the check job is ignored and the flag --external-sources is not passed to shellcheck. Even though the option is defined here, the job 13094 (shellcheck/check) fails with the error message:

source "$(dirname "${BASH_SOURCE[0]}")/_functions.sh"
       ^-- SC1091: Not following: ./dev-tools/_functions.sh was not specified as input (see shellcheck -x).

Expected behavior:

I expect the external_sources parameter in the workflow definition to be passed to shellcheck via the --external-sources flag.

Additional Information:

Digging deeper into the issue, I copied the orb code into my own CircleCI config and added a little bit of diagnostic output:

echo <<parameters.external_sources>>
echo $SC_PARAM_EXTERNAL_SOURCES

which outputs (see job 13098):

true
1

So I assume that boolean parameters are being converted to their int representation when they're passed to a command via the environment (testing the same with false set $SC_PARAM_EXTERNAL_SOURCES to 0.

Looking at the docs, the recommended way of using boolean parameters for flags seems to be:

shellcheck "$SHELLCHECK_EXCLUDE_PARAM" <<# parameters.external_sources >> --external-sources <</ parameters.external_sources >> "$SHELLCHECK_SHELL_PARAM" --severity="$SC_PARAM_SEVERITY" --format="$SC_PARAM_FORMAT" "$script" >> "$SC_PARAM_OUTPUT"

But I'm not sure if this works if the script is being included.