-
Notifications
You must be signed in to change notification settings - Fork 12
/
meld-bin
executable file
·44 lines (38 loc) · 973 Bytes
/
meld-bin
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
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
myname="${0##*/}"
usage() {
msg="$1\nUsage: $myname <FILE|DIR> <FILE|DIR> [FILE|DIR]\n"
if [[ "$TERM" == "dumb" ]] && type zenity >/dev/null 2>&1 ; then
msg="${msg//&/&}"
msg="${msg//</<}"
zenity --info --no-wrap --text "$msg"
else
printf "%b" "$msg" >&2
fi
exit 1
}
md5sumdir() (
cd "$1"
find . -type f -exec md5sum {} + | LC_ALL=C sort -f --key=2
)
case $# in
2|3)
tempdir=$(mktemp -d) || exit 1
trap 'rm -rf -- "$tempdir"' EXIT
i=0
{
echo # to start pulsating zenity's progress bar
while (( $# )) ; do
tempfile="${tempdir}/$((++i)) ${1//\//_}"
[[ -f "$1" ]] && hexdump -C "$1" > "$tempfile"
[[ -d "$1" ]] && md5sumdir "$1" > "$tempfile"
shift
done
} |
zenity --progress --pulsate --auto-close --auto-kill --title "$myname" \
--text "Comparing $*\n\nThis may take a long time.\n" \
>/dev/null 2>&1
;;
*) usage "$myname requires either 2 or 3 arguments";;
esac
meld "$tempdir"/*