summaryrefslogtreecommitdiffstats
path: root/git-ndim-sh/git-ndim-sh.in
blob: 6856629a2c6e417496c00ad11a5cab3dadb00722 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh

# Designed to be sourced.
case "$(basename "$0")" in
    git-ndim-sh|git-ndim-sh.in)
	echo "This script is not supposed to be executed." >&2
	echo "Source it instead." >&2
	exit 1
	;;
esac

if test "x$(pwd)" = "x`pwd`" && test "y$(echo "foobar")" = "y`echo foobar`"
then :;
else
    echo "$self: FATAL: This shell does not support POSIX sh \$() command substitution" >&2
    exit 1
fi

if test "x$(moo() { echo "meh"; }; moo)" = "xmeh"; then :;
else
    echo "$self: FATAL: This shell does not support POSIX sh functions" >&2
    exit 1
fi

bindir="$(cd "$(dirname "$0")" && pwd)"
prefixdir="$(dirname "$bindir")"

case "$1" in
    -V|--version)
	echo "$self (@PACKAGE_NAME@) @PACKAGE_VERSION@"
	exit 0
	;;
    -h|--help)
	for manpage in \
	    "${prefixdir}/share/man/man1/${self}.1.gz" \
	    "${prefixdir}/share/man/man1/${self}.1" \
	    "${prefixdir}/man/man1/${self}.1.gz" \
	    "${prefixdir}/man/man1/${self}.1" \
	    ;
	do
	    if test -s "$manpage"
	    then
		if man "$manpage" 2> /dev/null
		then
		    exit 0
		fi
	    fi
	done
	;;
esac