言午月月鸟
编程,带娃以及思考人生
首页
编程
带娃
思考人生
编程画图秀
一个检测项目中PHP文件是否有语法错误的脚本
dingusxp
938
脚本: php-check-syntax.sh ```sh cd `dirname $0` # set php path && scan depth (default) phpcmd=php depth=10 dir=. if [ $1 ] then dir=$1 fi if [ -d $dir ] then cd $dir dir=`pwd` else echo "invalid dir: $dir" exit 255 fi if [ $2 ] then depth=$2 fi if [ $depth -gt 100 ] then echo "invalid depth: $depth" exit 255 fi # check files in dir checkDir() { local phpcmd=$1 local dir=$2 local depth=$3 if [ ! -d $dir ] then return fi if [ $depth -lt 1 ] then return fi for file in `ls $dir` do path="$dir/$file" if [ ${path##*.} = "php" ] then checkRes=`$phpcmd -l $path` echo $checkRes | grep -v 'No syntax errors detected' fi if [ -d $path ] then checkDir "$phpcmd" "$path" $((depth-1)) fi done } checkDir "$phpcmd" "$dir" $depth ``` 使用: ``` sh php-check-syntax.sh /path/to/app 10 ```
粤ICP备19051469号-1
Copyright©dingusxp.com - All Rights Reserved
Template by
OS Templates