From: Hans-Christoph Steiner Date: Thu, 18 Sep 2014 17:56:11 +0000 (-0400) Subject: check the syntax of included shell scripts in the pre-commit hook X-Git-Tag: 0.3.0~27^2~2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e8a5d2b354c6a43ac7e57b17d61dc33c7892d5b6;p=fdroidserver.git check the syntax of included shell scripts in the pre-commit hook --- diff --git a/hooks/pre-commit b/hooks/pre-commit index f46dac4f..e7198e91 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -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