#!/bin/sh # Copyright 2010, The Regents of The University of Michigan, All Rights Reserved # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Diffs two text files code blocks. # # Bryan Smith - bryanesmith@gmail.com # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - usage() { cat <=${2}&&NR<=${3}" "$1" > $4 } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Main execution if [ "$#" -ne 6 ]; then error 1 "Error: Wrong number of arguments. Expected 6, but found: $#" fi # ~ Grab parameters ~ file1=$1 start1=$2 end1=$3 file2=$4 start2=$5 end2=$6 # ~ Check parameters ~ assertexists $file1 assertexists $file2 # ~ Copy text regions to temp files and diff ~ Temp1=".bdiff1" Temp2=".bdiff2" checktempfileexists $Temp1 checktempfileexists $Temp2 printportion "$file1" $start1 $end1 $Temp1 printportion "$file2" $start2 $end2 $Temp2 diff --ignore-all-space --ignore-blank-lines $Temp1 $Temp2 # ~ Clean up ~ rm $Temp1 rm $Temp2