blob: 0d093c72636020893efb23ab7e4b3daff4166077 (
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
|
# vim:ft=sh:noexpandtab
# Clever diff function
# TODO directory diff
# This function does diff and reports changes on debug level
# First and second arguments have to be paths to compared files and third argument
# have to be a debug message prepended string.
# It exits with nonzero exit code if there is no difference.
do_diff() {
if [ ! -f "$1" ]; then
echo_error "No reference file to compare to: $1"
return 1 # We pretend that there is no change as reference file is missing
fi
if [ ! -f "$2" ]; then
echo_dbg "$3: No target file"
return 0
fi
# Do real diff if both files exists
local DIFF="$(diff --suppress-common-lines -ay "$1" "$2")"
if [ -n "$DIFF" ]; then
echo_dbg "$3:
$DIFF"
else
return 1
fi
}
|