#!/usr/bin/env bash
# wrapper that runs Git's `diff-highlight` script if it's not in bin

paths=(
	# Arch
	/usr/share/git/diff-highlight
	# Debian
	/usr/share/doc/git/contrib/diff-highlight
)

for dir in "${paths[@]}"; do
	if [[ -f $dir/diff-highlight ]]; then
		exec perl $dir/diff-highlight "$@"
	elif [[ -f $dir/DiffHighlight.pm && -f $dir/diff-highlight.perl ]]; then
		exec perl -I$dir -MDiffHighlight $dir/diff-highlight.perl $@
	fi
done

echo "$0: error: could not find real diff-highlight" >&2
exit 3
