diff options
Diffstat (limited to 'bin/vipatch')
-rwxr-xr-x | bin/vipatch | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/bin/vipatch b/bin/vipatch index d860f93..ecb45c9 100755 --- a/bin/vipatch +++ b/bin/vipatch @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -f # vipatch -- edit unified diff @@ -6,7 +6,15 @@ # a patch generated by diff -u, depending on the actual # number of added/removed lines. -ep | awk -vname=${0##*/} ' +IFS='' + +tmp=$(mktemp /tmp/vipatch.XXXXXX) +trap 'rm $tmp; trap -' INT QUIT EXIT + +cat $1 > $tmp +${EDITOR:-vi} $tmp </dev/tty >/dev/tty + +cat $tmp | awk -vname=${0##*/} ' /^@@ / { if (head) printpatch(); head = $0 "\n"; next } head && /^---/ { print; next } head && /^\+\+\+/ { print; next } @@ -47,4 +55,4 @@ function printpatch() { function abs(n) { return (n > 0) ? n : -n; } -' +' | { [ -z "$1" ] && cat || cat > $1; } |