about summary refs log tree commit diff
path: root/xdiff
blob: a5dc9f4970307d12d0f1e76b631efaa61d1cd852 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
# xdiff [-u|-l] [DIR] - merge/diff/list XBPS .new-* files

mergeutil() {
	vimdiff "$1" "$2" && rm -vi "$1"
}

listutil() {
	printf '%s\n' "$1"
}

if [ "$1" = -u ]; then
	shift
	DIFF="diff -u"
elif [ "$1" = -l ]; then
	shift
	DIFF=listutil
else
	DIFF=mergeutil
fi

DIR=${1:-/etc}

for newfile in $(find "$DIR" -name '*.new-*_*'); do
	$DIFF "$newfile" "${newfile%.new-*_*}"
done