blob: 99a318cd32ba634ce1638fe33b8e066a52b077af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/bin/sh
#
# Git hook to run ShellCheck.
#
# ShellCheck <https://www.shellcheck.net/>
# Treat unset variables as an error when performing parameter expansion.
set -u
if ! command -v shellcheck >/dev/null; then
echo 'unable to locate shellcheck' >&2
return 0
fi
for f in $(git diff --cached --name-only); do
cmd=':'
case "${f}" in
shflags|shflags_test_helpers) cmd="shellcheck -s sh ${f}" ;;
*.sh) cmd="shellcheck ${f}" ;;
esac
if ! ${cmd}; then
echo "shellcheck error for '${f}'" >&2
fi
done
|