diff --git a/.github/workflows/scandir.yml b/.github/workflows/scandir.yml index c971c91..bc337b1 100644 --- a/.github/workflows/scandir.yml +++ b/.github/workflows/scandir.yml @@ -61,3 +61,19 @@ jobs: echo "::error:: Expected file $notexpect found in ${{ steps.two.outputs.files }}" exit 1 fi + + - name: Run ShellCheck + uses: ./ + id: three + with: + scandir: './testfiles/scandir' + all_scripts: true + + - name: Verify check + run: | + expect="testfiles/scandir/unknown-shebang" + + if [[ ! "${{ steps.three.outputs.files }}" =~ $expect ]];then + echo "::error:: Expected file $expect not found in ${{ steps.three.outputs.files }}" + exit 1 + fi diff --git a/action.yaml b/action.yaml index 130781e..b6417a0 100644 --- a/action.yaml +++ b/action.yaml @@ -6,6 +6,10 @@ inputs: description: "A space separated list of additional filename to check" required: false default: "" + all_scripts: + description: "Set to true to check all executable scripts. The default is to check only ones with known shebangs" + required: false + default: "" ignore: description: "Paths to ignore when running ShellCheck" required: false @@ -147,6 +151,7 @@ runs: shell: bash id: check env: + INPUT_ALL_SCRIPTS: ${{ inputs.all_scripts }} INPUT_SCANDIR: ${{ inputs.scandir }} INPUT_CHECK_TOGETHER: ${{ inputs.check_together }} INPUT_EXCLUDE_ARGS: ${{ steps.exclude.outputs.excludes }} @@ -155,7 +160,8 @@ runs: run: | statuscode=0 declare -a filepaths - shebangregex="^#! */[^ ]*/(env *)?[abk]*sh" + shebangregex="^#!" + [ "$INPUT_ALL_SCRIPTS" = "true" ] || shebangregex="^#! */[^ ]*/(env *)?[abk]*sh" set -f # temporarily disable globbing so that globs in inputs aren't expanded diff --git a/testfiles/scandir/unknown-shebang b/testfiles/scandir/unknown-shebang new file mode 100755 index 0000000..05ec3e9 --- /dev/null +++ b/testfiles/scandir/unknown-shebang @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv bashio + +echo "hi" \ No newline at end of file