#!/bin/bash # # $Id: prettycomp,v 1.2 1997/06/21 16:28:41 joi Exp joi $ # $Log: prettycomp,v $ # Revision 1.2 1997/06/21 16:28:41 joi # Added smarts for file testing and a default pattern. # # Revision 1.1 1997/05/24 20:48:37 joi # Initial revision # # # usage: prettycomp "pattern" File1 File2 # # compares source lines extracted from two pretty # source files. Parm one is a perl pattern that # picks the lines you want to display. A generic # pattern would be "[^@&]" which gets everything # that would create an attribute. The next two # parms are the files to compare. # # files are left behind on /tmp. # if [ $# = 3 ]; then file1=$2 file2=$3 patt=$1 else file1=$1 file2=$2 patt="^[&@]" fi temp1=/tmp/${file1##*/}.tmp echo "Temp file $temp1" temp2=/tmp/${file2##*/}.tmp echo "Temp file $temp2" diff=/tmp/${2##*/}.diff echo "Diff file $diff" if [ ! -f "$file1" ]; then echo "$file1 does not exist" exit 1 fi if [ ! -f "$file2" ]; then echo "$file2 does not exist" exit 2 fi echo "Mushing $file1 to $t1" unprettify "$patt" <$file1 | sort | prettify >$temp1 echo "Mushing $file2 to $temp2" unprettify "$patt" <$file2 | sort | prettify >$temp2 diff -s -i -B -b -c -F "$patt" $temp1 $temp2 >$diff if [ -s $diff ]; then more $diff fi