diff options
author | Karel Kočí <cynerd@email.cz> | 2017-09-20 21:19:05 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-09-20 21:22:36 +0200 |
commit | f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8 (patch) | |
tree | 5025b33a8c3d4c69ad2b62e1169b669c56f712f9 /utils/diff | |
parent | 65f52ead41dc6df73671ddd3a8c6a2edecb6dfb3 (diff) | |
download | multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.tar.gz multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.tar.bz2 multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.zip |
Commit current statecomplicated
Diffstat (limited to 'utils/diff')
-rw-r--r-- | utils/diff | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/utils/diff b/utils/diff new file mode 100644 index 0000000..0d093c7 --- /dev/null +++ b/utils/diff @@ -0,0 +1,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 +} |