summaryrefslogtreecommitdiff
path: root/vsvs-parse
blob: 27e51a4920455bd1f517ed481e49478dbdfbd692 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
# Iterate action over elements from VSVS input,
# action is passed as $1, it will be evaluated for each key-value pair.
after () { test -z "${2##*$1*}" && echo -n "${2#*$1}"; }
key=""
value=""
while IFS="" read line
do
    if test -z "${line%% *}"
    then value="${value}"$'\n'"$(after " " "$line")"
    else
        test -n "$key" && eval $1
        key="${line%% *}"
        value="$(after " " "$line")"
    fi
done
test -n "$key" && eval $1