File: dgit-functions.sh

package info (click to toggle)
dgit 14.3
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 4,396 kB
  • sloc: perl: 14,084; sh: 7,447; makefile: 346; python: 334; tcl: 69
file content (39 lines) | stat: -rw-r--r-- 682 bytes parent folder | download | duplicates (2)
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
# -*- bash -*-

fail () { echo >&2 "$us: error: $*"; exit 16; }
x () { echo >&2 "+ $*"; "$@"; }

parse-args-settings () {
    s_bpd=../bpd
    : ${DGIT_DRS_DGIT:=dgit}

    while [ $# != 0 ]; do
	case "$1" in
	    --*) fail "unknown option" ;;
	    *=*)
		k="${1%%=*}"
		v="${1#*=}"
		case "$k" in
		    *[^0-9a-z_]*) fail "bad syntax for setting" ;;
		    *)
			eval "s_$k=\$v"
			;;
		esac
		shift
		;;
	    *) fail "non-option arguments must all be settings K=V" ;;
	esac
    done
}

run-dgit () {
    x $DGIT_DRS_DGIT --build-products-dir="$s_bpd" -p"$s_p" "$@" >&2
}
report () {
    printf "%s\n" "$*"
    printf >&2 "# %s\n" "$*"
}
tempfail () {
    report "$*"
    exit 75
}