4be356a11ca648fb9115f5278266950f786b1aa9
[platform/upstream/mesa.git] / .gitlab-ci / run-shellcheck.sh
1 #!/usr/bin/env bash
2
3 CHECKPATH=".gitlab-ci/container"  # TODO: expand to cover whole .gitlab-ci/
4
5 is_bash() {
6     [[ $1 == *.sh ]] && return 0
7     [[ $1 == */bash-completion/* ]] && return 0
8     [[ $(file -b --mime-type "$1") == text/x-shellscript ]] && return 0
9     return 1
10 }
11
12 while IFS= read -r -d $'' file; do
13     if is_bash "$file" ; then
14         shellcheck -x -W0 -s bash "$file"
15         rc=$?
16         if [ "${rc}" -eq 0 ]
17         then
18             continue
19         else
20             exit 1
21         fi
22     fi
23 done < <(find $CHECKPATH -type f \! -path "./.git/*" -print0)