#!/bin/rc # # Diff standard input against $1 and produce a context style # diff which can be edited by hand to include modifications. # # Lines with: # # + are new # - reqire deletion # | should be replaced # ? should be substituted # if (! ~ $#* 1) { echo usage: `{basename $0} new-file >[1=2] exit usage } sed '/^[\-+\|\?.]/s/^/./' > /tmp/vidi.$pid diff -e /tmp/vidi.$pid $1 | awk ' cmd == "" { printf("%s", substr($1, 1, length($1) - 1)) cmd = substr($1, length($1), 1) if (cmd == "d") { print "s/^/-/" cmd = "" next } if (cmd == "c") { print "s/^/?/" char = "|" } else char = "+" print "a" next } $0 == "." { cmd = "" print $0 next } { print char $0 } END { print "1,$p" } ' > /tmp/vidi.e$pid ed - /tmp/vidi.$pid < /tmp/vidi.e$pid rm -f /tmp/vidi.*$pid