File: config-script.in

package info (click to toggle)
discover 2.1.2-7.1+deb9u1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 6,248 kB
  • sloc: sh: 8,115; ansic: 7,275; xml: 1,809; makefile: 732
file content (81 lines) | stat: -rw-r--r-- 1,179 bytes parent folder | download | duplicates (3)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#! /bin/sh

# $Progeny$$

# This program is in the public domain.

# Too bad we don't have something like sysexits.h for POSIX sh...
EX_USAGE=64

@PROGENY_CONFIG_SCRIPT_VARS@
@PROGENY_CONFIG_SCRIPT_SET@

usage ()
{
    cat <<EOF
usage: $0 --VAR ...

Print the value of the variable VAR.  Run $0 -l or $0 --list-vars for a list
of valid variable names.
EOF
}

listvars ()
{
    for i in ${VARS}; do
        echo ${i}
    done
}

have ()
{
    var=$1

    for i in ${VARS}; do
        if [ ${var} = ${i} ]; then
            return 0
        fi
    done

    return 1
}

###############################################################################

if [ $# -eq 0 ]; then
    usage
    exit ${EX_USAGE}
fi

while [ $# -gt 0 ]; do
    case $1 in
    -l|--list-vars)
        listvars
        break
        ;;

    --)
        usage
        exit ${EXIT_USAGE}
        ;;

    --*)
        var=$(echo $1 | sed -e 's/^--//' -e 's/-/_/g')
        if have ${var}; then
            eval val="\$${var}"
            echo ${val}
        else
            usage
            exit ${EX_USAGE}
        fi
        ;;

    *)
        usage
        exit ${EX_USAGE}
    esac

    shift
done

exit 0