Perl 5.10, PHP5.3 バージョンアップ時の簡易チェック

#!/bin/sh
ARGDIR=$1 

grep_and_warn (){
  LINE=$1
  MESSAGE=$2

  echo ${LINE}
  FILE=`echo ${LINE} | awk -F':' '{print $1}'`
  CODE=`echo ${LINE} | sed -e "s|^${FILE}||g"`
}

grep_and_warn_perl (){
  DIR=$1
  REGEX=$2
  MESSAGE=$3
  EXCLUDE=$4

  IFS=$'\n'

  if [ -n "${EXCLUDE}" ]; then
    LIST=`find ${DIR} -name '*.pl' -o -name '*.pm' -o -name '*.pmc' -o -name '*.cgi' | xargs egrep -r "${REGEX}" 2> /dev/null | grep -v "${EXCLUDE}"`
  else
    LIST=`find ${DIR} -name '*.pl' -o -name '*.pm' -o -name '*.pmc' -o -name '*.cgi' | xargs egrep -r "${REGEX}" 2> /dev/null`
    #LIST=`find ${DIR} ${FILE_FILTER} | xargs egrep -r "${REGEX}" 2> /dev/null`
  fi

  for LINE in ${LIST}
  do
    grep_and_warn "${LINE}" "${LIST}"
  done
}

grep_and_warn_php (){
  DIR=$1
  REGEX=$2
  MESSAGE=$3
  EXCLUDE=$4

  IFS=$'\n'

  if [ -n "${EXCLUDE}" ]; then
    LIST=`find ${DIR} -name '*.php' | xargs egrep -r "${REGEX}" 2> /dev/null | grep -v "${EXCLUDE}"`
  else
    LIST=`find ${DIR} -name '*.php' | xargs egrep -r "${REGEX}" 2> /dev/null`
    #LIST=`find ${DIR} ${FILE_FILTER} | xargs egrep -r "${REGEX}" 2> /dev/null`
  fi

  for LINE in ${LIST}
  do
    grep_and_warn "${LINE}" "${LIST}"
  done
}

grep_and_warn_perl "${ARGDIR}" "pack *\(" "【Perl5.10】pack() 及び unpack() を使っているところがないか確認して下さい。" "jcode.pl"
grep_and_warn_perl "${ARGDIR}" "\$\*" "【Perl5.10】\$\* 及び \$\# 変数は使えなくなったので該当箇所がないか" 
grep_and_warn_perl "${ARGDIR}" "\$\#" "【Perl5.10】\$\* 及び \$\# 変数は使えなくなったので該当箇所がないか"
grep_and_warn_perl "${ARGDIR}" "substr.*=" "【Perl5.10】" 
grep_and_warn_perl "${ARGDIR}" "-f *_" "【Perl5.10】" 
grep_and_warn_perl "${ARGDIR}" ":\s*unique" "【Perl5.10】" 
grep_and_warn_perl "${ARGDIR}" "\$\^H" "【Perl5.10】" 
grep_and_warn_perl "${ARGDIR}" "chdir" "【Perl5.10】" 
grep_and_warn_perl "${ARGDIR}" "\$\^V" "【Perl5.10】" 
grep_and_warn_perl "${ARGDIR}" "\@\-" "【Perl5.10】" 
grep_and_warn_perl "${ARGDIR}" "\@\+" "【Perl5.10】" 
grep_and_warn_perl "${ARGDIR}" "\(\?p\{" "【Perl5.10】" 
grep_and_warn_perl "${ARGDIR}" "AUTOLOAD" "【Perl5.10】"
grep_and_warn_perl "${ARGDIR}" "printf" "【Perl5.10】" "gaika.cgi"
grep_and_warn_perl "${ARGDIR}" "sprintf" "【Perl5.10】" "gaika.cgi"
grep_and_warn_perl "${ARGDIR}" "undef" "【Perl5.10】" "jcode.pl"
grep_and_warn_perl "${ARGDIR}" "defined \$\$" "【Perl5.10】" 
grep_and_warn_perl "${ARGDIR}" " \{[_a-zA-Z0-9]+\}\s*= " "【Perl5.10】" 

grep_and_warn_php "${ARGDIR}" "getrusage" "【PHP 5.2】"
grep_and_warn_php "${ARGDIR}" "ZipArchive::setCommentIndex" "【PHP 5.2】"
grep_and_warn_php "${ARGDIR}" "ZipArchive::setCommentName" "【PHP 5.2】"
grep_and_warn_php "${ARGDIR}" "getFilename" "【PHP 5.2】"
grep_and_warn_php "${ARGDIR}" "%.*===\? *FALSE" "【PHP 5.2】"
# grep_and_warn_php "${ARGDIR}" "" "【PHP 5.2】オブジェクトを配列の引数に指定しているところがないか"
grep_and_warn_php "${ARGDIR}" "abstract static function" "【PHP 5.2】"
grep_and_warn_php "${ARGDIR}" "oci_" "【PHP 5.2】"
grep_and_warn_php "${ARGDIR}" "grob" "【PHP 5.2】"

grep_and_warn_php "${ARGDIR}" "clearstatcache" "【PHP 5.3】"
grep_and_warn_php "${ARGDIR}" "realpath" "【PHP 5.3】"
grep_and_warn_php "${ARGDIR}" "call_user_func|call_user_func_array" "【PHP 5.3】"
grep_and_warn_php "${ARGDIR}" "natsort|natcasesort|usort|uasort|uksort|array_flip|array_unique" "【PHP 5.3】"
#grep_and_warn_php "${ARGDIR}" "" "【PHP 5.3】引数を参照渡しにする関数に値を渡している箇所はないか"
#grep_and_warn_php "${ARGDIR}" "mysql_" "【PHP 5.3】mysql_... 関数を使っている場合、移行前のMySQLが4.1以降か"
grep_and_warn_php "${ARGDIR}" "SplFileInfo" "【PHP 5.3】"
grep_and_warn_php "${ARGDIR}" "__toString\(.+\)" "【PHP 5.3】"
grep_and_warn_php "${ARGDIR}" "function *(__get|__set|__isset|__unset|__call)" "【PHP 5.3】"
grep_and_warn_php "${ARGDIR}" "__call" "【PHP 5.3】__call() でprivate、protectedメソッドを指定しているところがないか"
grep_and_warn_php "${ARGDIR}" "func_get_arg()|func_get_args()|func_num_args() " "【PHP 5.3】"
grep_and_warn_php "${ARGDIR}" "s2k" "【PHP 5.3】"
grep_and_warn_php "${ARGDIR}" "goto|namespace" "【PHP 5.3】"