summaryrefslogtreecommitdiff
path: root/gpgdiff
blob: cd134cadc67ec0dfd53cf5c70eb75feb1d821197 (plain)
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
27
28
29
30
31
32
33
34
#!/bin/sh

args=''
while : ; do
	case "$1" in
		-*) args="$args $1"; shift ;;
		*) break
	esac
done

if [ "$#" -lt 2 ]; then
	echo >&2 "Usage: $0 [-diffopts] <file1> <file2>"
	exit 1
fi

umask 077
tmp1="`tempfile`"
tmp2="`tempfile`"
trap "rm -f '$tmp1' '$tmp2'" EXIT

gpg --decrypt < "$1" > "$tmp1"
# gpg's exit codes sucks
if ! [ -s "$tmp1" ]; then
	echo >&2 "gpg decrypt of $f1 failed?"
	exit 1
fi

gpg --decrypt < "$2" > "$tmp2"
if ! [ -s "$tmp2" ]; then
	echo >&2 "gpg decrypt of $f2 failed?"
	exit 1
fi

diff $args "$tmp1" "$tmp2"