diff --git a/.github/workflows/Shellcheck.yml b/.github/workflows/Shellcheck.yml index f1171a0..e6765fe 100644 --- a/.github/workflows/Shellcheck.yml +++ b/.github/workflows/Shellcheck.yml @@ -35,5 +35,32 @@ jobs: - name: Execute test env: TERM: xterm-256color - PATH: "$PATH:${{ github.workspace }}/shellcheck" - run: ./test + + run: | + + declare -a ERRORS + declare -a FILES + + for file in "${FILES[@]}"; do + if /usr/bin/file "${file}" | /usr/bin/grep --quiet "shell" || \ + /usr/bin/file "${file}" | /usr/bin/grep --quiet "bash" || \ + /usr/bin/file "${file}" | /usr/bin/grep --quiet "zsh"; then + + if shellcheck --shell=bash "${shell_file}" ; then + echo "[PASS] $(/usr/bin/basename "${shell_file}")" + else + echo "[FAIL] $(/usr/bin/basename "${shell_file}")" + ERRORS+=("${shell_file}") + fi + fi + done + + if [[ ${#ERRORS[@]} -eq 0 ]]; then + # If ERRORS empty then + echo "[PASS] No errors, hooray" + exit 0 + else + # If ERRORS not empty, print the names of files which failed + echo "[FAIL] These files failed linting: ${ERRORS[*]}" + exit 1 + fi