summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-03-30 23:43:15 +0100
committerdavidovski <david@davidovski.xyz>2022-03-30 23:43:15 +0100
commit6a9a7caa59370e03a9db3da89280e51febe75149 (patch)
tree7983d102b2693fb88ca6b545e660ef04750b42bd /src
parentb69909628b42e2d063dcbdcbe7adaddf5e7ee047 (diff)
fixed parseconfv1.2.2
Diffstat (limited to 'src')
-rwxr-xr-xsrc/parseconf.sh28
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