summaryrefslogtreecommitdiff
path: root/.gitlab-ci/run-shellcheck.sh
blob: 4be356a11ca648fb9115f5278266950f786b1aa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash

CHECKPATH=".gitlab-ci/container"  # TODO: expand to cover whole .gitlab-ci/

is_bash() {
    [[ $1 == *.sh ]] && return 0
    [[ $1 == */bash-completion/* ]] && return 0
    [[ $(file -b --mime-type "$1") == text/x-shellscript ]] && return 0
    return 1
}

while IFS= read -r -d $'' file; do
    if is_bash "$file" ; then
        shellcheck -x -W0 -s bash "$file"
        rc=$?
        if [ "${rc}" -eq 0 ]
        then
            continue
        else
            exit 1
        fi
    fi
done < <(find $CHECKPATH -type f \! -path "./.git/*" -print0)