1
0
mirror of https://github.com/albfan/bash-ini-parser.git synced 2025-08-06 07:02:37 +03:00

move comments to debug

This commit is contained in:
albfan
2018-01-22 22:53:44 +01:00
parent 4e9ab7ab5c
commit b55c55f5fd

View File

@@ -26,10 +26,11 @@ function cfg_parser {
fi fi
ini="$(<$1)" # read the file ini="$(<$1)" # read the file
ini=${ini//$'\r'/} # remove linefeed i.e dos2unix ini=${ini//$'\r'/} # remove linefeed i.e dos2unix
ini="${ini//[/\\[}" # escape [
debug ini="${ini//[/\\[}"
ini="${ini//]/\\]}" # escape ] debug "escaped ["
debug ini="${ini//]/\\]}"
debug "escaped ]"
IFS=$'\n' && ini=( ${ini} ) # convert to line-array IFS=$'\n' && ini=( ${ini} ) # convert to line-array
debug debug
ini=( ${ini[*]//;*/} ) # remove comments with ; ini=( ${ini[*]//;*/} ) # remove comments with ;
@@ -37,7 +38,9 @@ function cfg_parser {
ini=( ${ini[*]//\#*/} ) # remove comments with # ini=( ${ini[*]//\#*/} ) # remove comments with #
debug debug
ini=( ${ini[*]/#+([[:space:]])/} ) # remove init whitespace ini=( ${ini[*]/#+([[:space:]])/} ) # remove init whitespace
debug "whitespace around" debug
ini=( ${ini[*]/%+([[:space:]])/} ) # remove ending whitespace
debug "whitespace around ="
ini=( ${ini[*]/*([[:space:]])=*([[:space:]])/=} ) # remove whitespace around = ini=( ${ini[*]/*([[:space:]])=*([[:space:]])/=} ) # remove whitespace around =
debug debug
ini=( ${ini[*]/#\\[/\}$'\n'"$PREFIX"} ) # set section prefix ini=( ${ini[*]/#\\[/\}$'\n'"$PREFIX"} ) # set section prefix