Created
November 26, 2010 14:22
-
-
Save skiold/716773 to your computer and use it in GitHub Desktop.
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() { | |
IFS=$'\n' && ini=( $(<$1) ) # convert to line-array | |
ini=( ${ini[*]//;*/} ) # remove comments ; | |
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 | |
ini[0]='' # remove first element | |
ini[${#ini[*]} + 1]='}' # add the last brace | |
eval "$(echo "${ini[*]}")" # eval the result | |
} | |
cfg_parser ./scripts/wrapper_config | |
cfg.section.dummy | |
echo "${XVA_DUMP_DIR}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment