Advertisement
Guest User

ajdiaz

a guest
Jun 20th, 2008
1,159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.77 KB | None | 0 0
  1. cfg.parser () {
  2.     IFS=$'\n' && ini=( $(<$1) )              # convert to line-array
  3.     ini=( ${ini[*]//;*/} )                   # remove comments
  4.     ini=( ${ini[*]/#[/\}$'\n'cfg.section.} ) # set section prefix
  5.     ini=( ${ini[*]/%]/ \(} )                 # convert text2function (1)
  6.     ini=( ${ini[*]/=/=\( } )                 # convert item to array
  7.     ini=( ${ini[*]/%/ \)} )                  # close array parenthesis
  8.     ini=( ${ini[*]/%\( \)/\(\) \{} )         # convert text2function (2)
  9.     ini=( ${ini[*]/%\} \)/\}} )              # remove extra parenthesis
  10.     ini[0]=''                                # remove first element
  11.     ini[${#ini[*]} + 1]='}'                  # add the last brace
  12.     eval "$(echo "${ini[*]}")"               # eval the result
  13. }
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement