Add hooks to check .sh and .bash headers - Fixes #1491 (#1765)

* Add hooks to check .sh and .bash headers
* Adds hooks/ to clean_files.txt
This commit is contained in:
David Farrell
2021-01-09 08:02:26 -08:00
committed by GitHub
parent 3fce1ffe8d
commit e932d8371f
18 changed files with 71 additions and 12 deletions

21
hooks/dot-bash.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
exit_code=0
for file in "$@"; do
# Confirm file is not executable
#
if [[ -x "${file}" ]]; then
echo "Bash include file \`${file}\` should not be executable"
exit_code=1
fi
# Confirm expected schellcheck header
#
LINE1="$(head -n 1 "${file}")"
if [[ "${LINE1}" != "# shellcheck shell=bash" ]]; then
echo "Bash include file \`${file}\` has bad/missing shellcheck header"
exit_code=1
fi
done
exit $exit_code