Beef up the cmp.sh script output

This commit is contained in:
Geoff R. McLane 2015-09-17 13:42:43 +02:00
parent 70d2d5dc66
commit 55bb3fe0f0

View file

@ -8,6 +8,7 @@ BN=`basename $0`
TMPDIR1=$1
TMPDIR2=$2
OUTLOG="temp.diff"
TMPDOP="-ua"
usage()
{
@ -15,10 +16,15 @@ usage()
echo "Usage: ./$BN directory1 directory2"
echo ""
echo "$BN: If you have the tidied HTML output from two version of 'tidy' then "
echo "$BN: this can COMPARE the html files ONE BY ONE, output to $OUTLOG"
echo "$BN: this can COMPARE the output files ONE BY ONE, output to $OUTLOG"
echo ""
}
d_now()
{
date +%Y%m%d%H%M%S
}
if [ -z "$TMPDIR1" ] || [ -z "$TMPDIR2" ] || [ "$TMPDIR1" = "--help" ] || [ "$TMPDIR1" = "-h" ] || [ "$TMPDIR1" = "-?" ]; then
usage
exit 1
@ -27,12 +33,13 @@ fi
if [ ! -d "$TMPDIR1" ]; then
usage
echo "$BN: Can NOT locate directory '$TMPDIR1'!"
echo "$BN: Can NOT locate directory 1 '$TMPDIR1'!"
exit 1
fi
if [ ! -d "$TMPDIR2" ]; then
usage
echo "$BN: Can NOT locate directory 2 '$TMPDIR2'!"
exit 1
fi
@ -43,45 +50,60 @@ TMPCNT1=0
TMPCNT2=0
SAMECNT=0
DIFFCNT=0
DIFFFILES=""
for fil in $TMPDIR1/*.html; do
# 20150917 - Maybe should be ALL, not just html
TMPMASK="*"
# TMPMASK="*.html"
for fil in $TMPDIR1/$TMPMASK; do
TMPCNT1=`expr $TMPCNT1 + 1`
done
for fil in $TMPDIR2/*.html; do
for fil in $TMPDIR2/$TMPMASK; do
TMPCNT2=`expr $TMPCNT2 + 1`
done
echo "$BN: Found $TMPCNT1 html files in $TMPDIR1"
echo "$BN: Found $TMPCNT2 html files in $TMPDIR2"
echo "$BN: Found $TMPCNT1 files in $TMPDIR1"
echo "$BN: Found $TMPCNT2 files in $TMPDIR2"
if [ -f "$OUTLOG" ]; then
rm -f $OUTLOG
fi
echo "$BN: Found $TMPCNT1 html files in $TMPDIR1" >> $OUTLOG
echo "$BN: Found $TMPCNT2 html files in $TMPDIR2" >> $OUTLOG
TMPNOW=`d_now`
echo "$BN: Compare of '$TMPDIR1' and '$TMPDIR2' on $TMPNOW" >> $OUTLOG
echo "$BN: Found $TMPCNT1 files in $TMPDIR1" >> $OUTLOG
echo "$BN: Found $TMPCNT2 files in $TMPDIR2" >> $OUTLOG
for fil in $TMPDIR1/*.html; do
for fil in $TMPDIR1/$TMPMASK; do
bfil=`basename $fil`
if [ -f "$TMPDIR2/$bfil" ]; then
diff -uw $TMPDIR1/$bfil $TMPDIR2/$bfil >> $OUTLOG
diff $TMPDOP $TMPDIR1/$bfil $TMPDIR2/$bfil >> $OUTLOG
if [ "$?" = "0" ]; then
echo "diff -uw $TMPDIR1/$bfil $TMPDIR2/$bfil are the SAME" >> $OUTLOG
echo "diff $TMPDOP $TMPDIR1/$bfil $TMPDIR2/$bfil are the SAME" >> $OUTLOG
SAMECNT=`expr $SAMECNT + 1`
else
echo "diff $TMPDOP $TMPDIR1/$bfil $TMPDIR2/$bfil are DIFFERENT! *** CHECK DIFFERENCE ***" >> $OUTLOG
DIFFCNT=`expr $DIFFCNT + 1`
DIFFFILES="$DIFFFILES $bfil"
fi
else
echo "$BN: File $bfil not found the 2" >> $OUTLOG
echo "$BN: File $bfil not found in dir 2 $TMPDIR2" >> $OUTLOG
fi
done
TOTCNT=`expr $SAMECNT + $DIFFCNT`
echo "" >> $OUTLOG
echo "$BN: Of the $TOTCNT compares made, $SAMECNT are the SAME, $DIFFCNT are DIFFERENT"
echo "$BN: Of the $TOTCNT compares made, $SAMECNT are the SAME, $DIFFCNT are DIFFERENT" >> $OUTLOG
if [ ! "$DIFFCNT" = "0" ]; then
echo "$BN: VERIFY $DIFFCNT $DIFFFILES"
echo "$BN: VERIFY $DIFFCNT $DIFFFILES" >> $OUTLOG
fi
echo "" >> $OUTLOG
echo "$BN: Results are in $OUTLOG"
echo "$BN: Full results are in $OUTLOG"
echo ""
# eof