This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cfg.parser () { | |
fixed_file=$(cat $1 | sed 's/ = /=/g') # fix ' = ' to be '=' | |
IFS=$'\n' && ini=( $fixed_file ) # convert to line-array | |
ini=( ${ini[*]//;*/} ) # remove comments | |
ini=( ${ini[*]/#[/\}$'\n'cfg.section.} ) # set section prefix | |
ini=( ${ini[*]/%]/ \(} ) # convert text2function (1) | |
ini=( ${ini[*]/=/=\( } ) # convert item to array | |
ini=( ${ini[*]/%/ \)} ) # close array parenthesis | |
ini=( ${ini[*]/%\( \)/\(\) \{} ) # convert text2function (2) | |
ini=( ${ini[*]/%\} \)/\}} ) # remove extra parenthesis |