diff options
author | John Ankarström <john@ankarstrom.se> | 2021-07-27 22:33:03 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-07-27 22:33:03 +0200 |
commit | 2a988d33c5e48a2e4a6d004df84628890bb41f29 (patch) | |
tree | 0760247ca8f38017a9eb0bb80501f993c95d9a4c /bin | |
parent | a6926740758524f2c10db70b851d8fc6809e9242 (diff) | |
download | patches-2a988d33c5e48a2e4a6d004df84628890bb41f29.tar.gz |
vipatch: Edit given file
Diffstat (limited to 'bin')
-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; } |