chiark / gitweb /
check the syntax of included shell scripts in the pre-commit hook
authorHans-Christoph Steiner <hans@eds.org>
Thu, 18 Sep 2014 17:56:11 +0000 (13:56 -0400)
committerHans-Christoph Steiner <hans@eds.org>
Thu, 23 Oct 2014 18:26:11 +0000 (14:26 -0400)
hooks/pre-commit

index f46dac4fdf086eb5abf24c8cf15a5ffd30f200a6..e7198e91db1a9a06bc3150d7b82a5c61c33e3400 100755 (executable)
@@ -32,3 +32,27 @@ fi
 # If there are python errors or warnings, print them and fail.
 [ -n $PYFLAKES ] && $PYFLAKES $FILES
 [ -n $PEP8 ] && $PEP8 --ignore=E123,E501 $FILES
+
+
+#------------------------------------------------------------------------------#
+# check the syntax of included shell scripts
+
+basedir=`cd $(dirname $0)/.. && pwd`
+echo basedir: $basedir
+
+if [ $(basename $basedir) = ".git" ]; then
+    basedir=$(dirname $basedir)
+fi
+
+exitstatus=0
+# use bash to check that the syntax is correct
+for f in $basedir/fd-commit $basedir/jenkins-build $basedir/docs/*.sh $basedir/hooks/pre-commit; do
+    if bash -n $f; then
+        : # success! do nothing
+    else
+        echo "FAILED!"
+        exitstatus=1
+    fi
+done
+
+exit $exitstatus