Created
July 5, 2017 19:26
-
-
Save thomxc/cd95ba66016f83e1aea577282fae6b7f to your computer and use it in GitHub Desktop.
phplint shell script using directories or files as input and outputting exit codes
This file contains 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 | |
error=false | |
echo "Starting phplint.." | |
while test $# -gt 0; do | |
current=$1 | |
shift | |
if [ ! -d $current ] && [ ! -f $current ] ; then | |
echo "Invalid directory or file: $current" | |
error=true | |
continue | |
fi | |
for file in `find $current -type f -name "*.php"` ; do | |
RESULTS=`php -l $file` | |
if [ "$RESULTS" != "No syntax errors detected in $file" ] ; then | |
error=true | |
fi | |
echo $RESULTS | |
done | |
done | |
if [ "$error" = true ] ; then | |
exit 1 | |
else | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment