aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/pre-commit/bash_syntax22
1 files changed, 22 insertions, 0 deletions
diff --git a/contrib/pre-commit/bash_syntax b/contrib/pre-commit/bash_syntax
new file mode 100755
index 0000000..7e014e8
--- /dev/null
+++ b/contrib/pre-commit/bash_syntax
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+function test_file {
+ file="${1}"
+ head -n 1 "${file}" | grep 'bash' | grep '^#!/' > /dev/null
+ if [ "$?" -eq 0 ] ; then
+ set -e
+ bash -n "${file}"
+ set +e
+ fi
+}
+
+case "${1}" in
+ --about )
+ echo "Check bash shell scripts for syntax errors."
+ ;;
+ * )
+ for file in `git diff-index --cached --name-only HEAD` ; do
+ test_file "${file}"
+ done
+ ;;
+esac