1
0
mirror of https://github.com/albfan/bash-ini-parser.git synced 2025-04-21 00:07:46 +03:00

Better debug messages

This commit is contained in:
Alberto Fanjul 2020-08-28 20:02:43 +02:00
parent 9368387ce8
commit f19ab7e76b

View File

@ -33,17 +33,17 @@ function cfg_parser {
IFS=$'\n' && ini=( ${ini} ) # convert to line-array IFS=$'\n' && ini=( ${ini} ) # convert to line-array
debug debug
ini=( ${ini[*]/#*([[:space:]]);*/} ) ini=( ${ini[*]/#*([[:space:]]);*/} )
debug "remove ; comments" debug "removed ; comments"
ini=( ${ini[*]/#*([[:space:]])\#*/} ) ini=( ${ini[*]/#*([[:space:]])\#*/} )
debug "remove # comments" debug "removed # comments"
ini=( ${ini[*]/#+([[:space:]])/} ) # remove init whitespace ini=( ${ini[*]/#+([[:space:]])/} ) # remove init whitespace
debug debug "removed initial whitespace"
ini=( ${ini[*]/%+([[:space:]])/} ) # remove ending whitespace ini=( ${ini[*]/%+([[:space:]])/} ) # remove ending whitespace
debug "whitespace around =" debug "removed ending whitespace"
ini=( ${ini[*]/%+([[:space:]])\\]/\\]} ) # remove non meaningful whitespace after sections ini=( ${ini[*]/%+([[:space:]])\\]/\\]} ) # remove non meaningful whitespace after sections
debug "whitespace around =" debug "removed whitespace after section name"
ini=( ${ini[*]/*([[:space:]])=*([[:space:]])/=} ) # remove whitespace around = ini=( ${ini[*]/*([[:space:]])=*([[:space:]])/=} ) # remove whitespace around =
debug debug "removed space around ="
ini=( ${ini[*]/#\\[/\}$'\n'"$PREFIX"} ) # set section prefix ini=( ${ini[*]/#\\[/\}$'\n'"$PREFIX"} ) # set section prefix
debug debug
for ((i=0; i < "${#ini[@]}"; i++)) for ((i=0; i < "${#ini[@]}"; i++))