summaryrefslogtreecommitdiff
path: root/test/conftest
blob: e202e87e17352e1f1d5d2beefba17073a5985fbe (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
#!/bin/sh

CONFIG_DIR=./configs
CONFIGS=`/usr/bin/find ${CONFIG_DIR} -type f -exec /usr/bin/grep -v -e ^\# -e ^$ {} \; -exec /bin/echo [] \; 2> /dev/null`

parse_lines() {
    unset in_sect
    while read line; do
        case ${line## } in
            \[*\])  v="${line#*[}"; v="${v%%]*}"
                    case $select in
                        ${v}) echo Starting our section "${select}" >&2
                              in_sect=true
                              ;;
                        *)    [ "${in_sect}" ] && echo Ending our section "${select}" >&2
                              echo Start other section "${v}" >&2
                              unset in_sect
                              ;;
                    esac
                    ;;
            env.*)  echo "### ${line} ### ${in_sect} ###" >&2
                    [ "${in_sect}" ] || continue
                    echo Setting environment: ${line#*env.} >&2
                    _pref=${line#*env.}; _suf=${_pref#* }
                    printf "%s " ${_pref%% *}=\'${_suf}\'
                    ;;
            *)      echo Ignoring ${line} >&2
                    ;;
        esac
    done
}

select=blubber
_env=$( printf "%s\n" "${CONFIGS}" | parse_lines )

printf "%s\n" "${_env}"
eval env ${_env} printenv