Skip to content

Instantly share code, notes, and snippets.

@wgm89
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save wgm89/f85e945cc09f6615cb68 to your computer and use it in GitHub Desktop.

Select an option

Save wgm89/f85e945cc09f6615cb68 to your computer and use it in GitHub Desktop.
syntaxCheck
#!/bin/bash
search_dir=$1
i=0
error_files=()
if [ ! $search_dir ]; then
search_dir='.'
fi
if [ -f "$search_dir" ];then
ck_result=`php -l $search_dir`
echo $ck_result
pre=${ck_result:0:9}
if [ "$pre" != "No syntax" ]; then
let i+=1
error_files[$i]="$entry"
fi
elif [ -d "$search_dir" ];then
for entry in "$search_dir"/*
do
case $entry in
*.php)
ck_result=`php -l $entry`
pre=${ck_result:0:9}
if [ "$pre" != "No syntax" ]; then
let i+=1
error_files[$i]="$entry"
fi
echo $ck_result ;;
*);;
esac
done
else
echo "file or dir not exists"
fi
echo "error_num: "${#error_files[@]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment