#!/bin/ksh #set -x opt=$1 if [ "${opt#-}" != "$opt" ]; then shift 1 else opt= fi dir1=$1 if [ "${dir1#/}" = "$dir1" ]; then # relative path dir1=$PWD/$dir1 fi dir2=$2 if [ "${dir2#/}" = "$dir2" ]; then # relative path dir2=$PWD/$dir2 fi interactive=1 tempres=/tmp/tempres.$$ if [ ! -d $dir1 ]; then echo "$dir1 not a directory" exit 1 fi if [ ! -d $dir2 ]; then echo "$dir1 not a directory" exit 1 fi cd $dir1 let i=0 for line in `find * -type f -print |\ egrep 'akefile|\.(pc|c|h|y|l|sql|cpp|inc|hpp)$' |\ egrep -v '/\.[a-zA-Z]' |\ egrep -v 'tags|ID'` do diff $opt $line $dir2/$line > $tempres if [ $? = 0 ]; then result[i]="identical" else if [ ! -f $line ]; then result[i]="invalid, $dir1/$line missing" elif [ ! -f $dir2/$line ]; then result[i]="invalid, $dir2/$line missing" else line_diff=`sed -n '2,$p' $tempres | egrep -v 'SCCS_LONGVERSION|SCCS_VERSION|---' | wc -l` result[i]="different with $line_diff lines different" fi fi fname[i]=$line let i=i+1 done rm -f $tempres let j=0 while (( j < i )); do echo "${fname[j]} is ${result[j]}" let j=j+1 done echo "Would you like to see the differences?(y|Y)" read resp if [ "$resp" = "Y" ] || [ "$resp" = "y" ]; then let j=0 while (( j < i )); do if [ "${result[j]}" != "identical" ] && [ "${result[j]%missing}" = "${result[j]}" ]; then echo "${fname[j]}" diff $opt ${fname[j]} $dir2/${fname[j]} echo "" echo "" if [ "$interactive" = "1" ]; then echo "next file?" read fi fi let j=j+1 done else let j=0 while (( j < i )); do if ([ "${result[j]}" != "different with 0 lines different" ] || [ "${result[j]}" != "identical" ]) && [ "${result[j]%missing}" = "${result[j]}" ]; then echo "diff $opt $dir1/${fname[j]} $dir2/${fname[j]}" fi let j=j+1 done fi