diff options
author | davidovski <david@davidovski.xyz> | 2022-03-30 23:43:15 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-03-30 23:43:15 +0100 |
commit | 6a9a7caa59370e03a9db3da89280e51febe75149 (patch) | |
tree | 7983d102b2693fb88ca6b545e660ef04750b42bd /src | |
parent | b69909628b42e2d063dcbdcbe7adaddf5e7ee047 (diff) |
fixed parseconfv1.2.2
Diffstat (limited to 'src')
-rwxr-xr-x | src/parseconf.sh | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/parseconf.sh b/src/parseconf.sh index 929ce05..abc6b36 100755 --- a/src/parseconf.sh +++ b/src/parseconf.sh @@ -23,22 +23,38 @@ parse_line() { shift local value="$@" - [ "$key" = "include" ] && cat $value | parse && return - [ "$key" = "]" ] && unset list=${list%.*} && printf "\n" && return - [ "$key" = "}" ] && unset level=${level%.*} && return + case $key in + "include") + cat $value | parse + return + ;; + "]") + IFS=. + set -- $list + list="${*%${!#}}" + IFS=" " + printf "\n" + return + ;; + "}") + [ "$level" = "${level%.*}" ] && + level="" || level=${level%.*} + return + ;; + esac case ${value##* } in "{") - level="${level}${key}." + level="${level}${level:+.}${key}" ;; "[") list="${list}${list:+.}${key}" - printf "$level$key:" + printf "$level${level:+.}$key:" ;; *) [ "${#list}" = "0" ] && - printf "$level$key:$value\n" || + printf "$level${level:+.}$key:$value\n" || printf "$line " ;; esac |