c9404d22c1097f7639c31fbb4c7d759d58907d85
3 # Note: This shell script should be designed and tested for cross-platform use
5 # URL: https://github.com/totten/git-php-syntax-checker/
6 # Author: Remigijus Jarmalavičius <remigijus@jarmalavicius.lt>
7 # Author: Vytautas Povilaitis <php-checker@vytux.lt>
11 LIST
=$
(git diff-index
--cached --name-only --diff-filter=ACMR HEAD
)
15 EXTENSION
=$
(echo "$file" |
grep -E ".php$|.module$|.inc$|.install$")
16 if [ "$EXTENSION" != "" ]; then
17 ERRORS
=$
(php
-l $ROOT_DIR$file 2>&1 |
grep "Parse error")
18 if [ "$ERRORS" != "" ]; then
19 if [ "$ERRORS_BUFFER" != "" ]; then
20 ERRORS_BUFFER
="$ERRORS_BUFFER\n$ERRORS"
22 ERRORS_BUFFER
="$ERRORS"
24 echo "Syntax errors found in file: $file "
28 if [ "$ERRORS_BUFFER" != "" ]; then
30 echo "These errors were found in try-to-commit files: "
31 echo -e $ERRORS_BUFFER
33 echo "Can't commit, fix errors first."
36 echo "Committed successfully."