# 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 }