Created
December 16, 2016 10:56
-
-
Save andyg1/9d43c9f7e615ba59e669068e6e4db627 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# checks any .php files that are edited in the current branch for syntax errors | |
# reports a list of files, putting errors in red and reporting the error and line number | |
FILES=$(git status -s | grep '\.php$') | |
for f in $FILES | |
do | |
if [[ $f =~ ^.*\.php$ ]]; then | |
RESULT=$(php -l $f 2>&1) | |
if [[ ! $RESULT == *"No syntax errors detected"* ]] || [[ $RESULT == *"on line"* ]]; then | |
RESULT="\033[31m$RESULT\e[0m" | |
fi | |
echo -e "$RESULT" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment