#!/bin/sh # # Copyright © 2013 Jonas Smedegaard # Description: Generate word-based diff for console or web # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Depends: libtext-worddiff-perl (>= 0.08) # # TODO: rewrite as Perl script, using HTML::HTML5::Builder set -e if [ -z "$3" ]; then perl -MText::WordDiff -E 'say word_diff "'"$1"'", "'"$2"'", { STYLE => 'ANSIColor' }' exit fi cat > "$3" < EOF perl -MText::WordDiff -E 'say word_diff "'"$1"'", "'"$2"'", { STYLE => "HTMLTwoLines" }' >> "$3" cat >> "$3" < EOF