]> git.wh0rd.org Git - home.git/blob - .bin/diff-highlight
git-rb-all: handle more edge cases
[home.git] / .bin / diff-highlight
1 #!/bin/sh
2
3 set -e
4
5 SCRIPT="$(readlink -f "$0")"
6 TARGET="${SCRIPT}.real"
7
8 main() {
9         # Some (old?) versions of git provided the compiled script.
10         d="/usr/share/doc/git/contrib/diff-highlight"
11         if [ -x "${d}/diff-highlight" ] ; then
12                 exec "${d}/diff-highlight"
13         fi
14
15         # See if we need to bootstrap first.
16         if [ ! -x "${TARGET}" ] && [ -e "${d}" ] ; then
17                 (
18                 echo "#!/usr/bin/env perl"
19                 cat "${d}/DiffHighlight.pm" "${d}/diff-highlight.perl"
20                 ) >"${TARGET}"
21                 chmod a+rx "${TARGET}"
22         fi
23
24         # If we've already bootstrapped, use it.
25         if [ -x "${TARGET}" ] ; then
26                 exec "${TARGET}" "$@"
27         else
28                 # Fallback so .gitconfig setings always work.
29                 exec cat
30         fi
31 }
32
33 main "$@"