#!/bin/sh set -e SCRIPT="$(readlink -f "$0")" TARGET="${SCRIPT}.real" main() { # Some (old?) versions of git provided the compiled script. d="/usr/share/doc/git/contrib/diff-highlight" if [ -x "${d}/diff-highlight" ] ; then exec "${d}/diff-highlight" fi # See if we need to bootstrap first. if [ ! -x "${TARGET}" ] && [ -e "${d}" ] ; then ( echo "#!/usr/bin/env perl" cat "${d}/DiffHighlight.pm" "${d}/diff-highlight.perl" ) >"${TARGET}" chmod a+rx "${TARGET}" fi # If we've already bootstrapped, use it. if [ -x "${TARGET}" ] ; then exec "${TARGET}" "$@" elif [ -x "/usr/bin/diff-highlight" ] ; then exec /usr/bin/diff-highlight "$@" else # Fallback so .gitconfig setings always work. exec cat fi } main "$@"