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
ini="$(<$1)" # read the file
ini=${ini//$'\r'/} # remove linefeed i.e dos2unix
ini="${ini//[/\\[}" # escape [
debug
ini="${ini//]/\\]}" # escape ]
debug
ini="${ini//[/\\[}"
debug "escaped ["
ini="${ini//]/\\]}"
debug "escaped ]"
IFS=$'\n' && ini=( ${ini} ) # convert to line-array
debug
ini=( ${ini[*]//;*/} ) # remove comments with ;
@@ -37,7 +38,9 @@ function cfg_parser {
ini=( ${ini[*]//\#*/} ) # remove comments with #
debug
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 =
debug
ini=( ${ini[*]/#\\[/\}$'\n'"$PREFIX"} ) # set section prefix