1#!/bin/sh
2
3# khard requires the second file in the diff-operation to be modified in order
4# to recognize a successful merge. However the file provided to sdiff's "-o"
5# switch cannot be any of the source files.
6#
7# If you want to use sdiff to merge contacts you must set this wrapper script
8# as your merge editor in khard's config file
9#
10# merge_editor = /path/to/sdiff_khard_wrapper.sh
11
12set -e
13
14# First and second argument to sdiff.
15FIRST=$1
16SECOND=$(mktemp)
17
18# Cleanup for signals and normal exit.
19trap 'trap "" EXIT; rm -f "$SECOND"; exit' INT HUP TERM
20trap 'rm -f "$SECOND"' EXIT
21
22# Free the filename that khard expects to change.
23mv -f "$2" "$SECOND"
24sdiff "$FIRST" "$SECOND" -o "$2"
25