From a9864baae64ff6f443562da03ea18265753cc8bf Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 30 Jun 2018 22:59:52 +0200 Subject: [PATCH] Implement shell linting --- Hooks/syntax.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Hooks/syntax.sh b/Hooks/syntax.sh index 562eb23..d7b4263 100644 --- a/Hooks/syntax.sh +++ b/Hooks/syntax.sh @@ -2,9 +2,8 @@ git diff --cached --name-only | while read FILE; do -if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then +if [[ "$FILE" =~ ^.+(php)$ ]]; then if [[ -f $FILE ]]; then - # php lint php -l "$FILE" 1> /dev/null if [ $? -ne 0 ]; then @@ -28,4 +27,15 @@ if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then fi fi +if [[ "$FILE" =~ ^.+(sh)$ ]]; then + if [[ -f $FILE ]]; then + # sh lint + bash -n "$FILE" 1> /dev/null + if [ $? -ne 0 ]; then + echo -e "\e[1;31m\tBash linting error.\e[0m" >&2 + exit 1 + fi + fi +fi + done || exit $?