Add shellcheck as a pre-commit hook
This commit is contained in:
parent
6b24f2d7a2
commit
bdb61a02cc
1 changed files with 27 additions and 0 deletions
27
pre-commit
Executable file
27
pre-commit
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
has() {
|
||||||
|
if (( $# )); then
|
||||||
|
hash "$1" 2>/dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
is_a() {
|
||||||
|
if (( $# > 1 )); then
|
||||||
|
head -1 "$1" | grep -qE '^#!.*'"$2"'$'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
find . -name .DS_Store -exec rm -f -- {} +
|
||||||
|
|
||||||
|
git status -zu | while read -rd '' xy filename; do
|
||||||
|
if [[ $xy = "??" || $xy = D ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $filename = *.sh ]] || is_a "$filename" bash; then
|
||||||
|
if has shellcheck; then
|
||||||
|
shellcheck -s bash "$filename"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in a new issue