Skip to content

Instantly share code, notes, and snippets.

@thomxc
Created July 5, 2017 19:26
Show Gist options
  • Save thomxc/cd95ba66016f83e1aea577282fae6b7f to your computer and use it in GitHub Desktop.
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
#!/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