Egyszerű INI értelmező is kell a dologhoz, így nem lesz gond a pythonos cuccokkal sem. Nyilván a korábbi szótár függvénnyel kell kombinálni és jó lesz a dologból.
#/// \fn sp_f_ii #/// \brief ini file to dictionary #/// #/// \param 1 CHARACTER(*) section header #/// \param 2 CHARACTER(*) path of the ini file #/// #/// http://docs.python.org/library/configparser.html #/// only single line entries are supported without % resolving function sp_f_ii() { local _h="${1:-${sp_g_bn}}" local _p="${2:-./${sp_g_bn%%sh}ini}" cat "${_p}" | \ awk -v h="${_h}" ' BEGIN { inh = 0; aas = "{"; fir = 1; kc = 0; } { # section header if( match( $0, "^[[:space:]]*\\[[[:space:]]*[[:alnum:]._-]+[[:space:]]*\\][[:space:]]*$" ) ) { # trim gsub("^[[:space:]]*\\[[[:space:]]*", "" ) gsub("[[:space:]]*\\][[:space:]]*$", "" ) # match if( match( $0, "^" h "$" ) ) { inh = 1; } else { inh = 0; } } # in section if( inh ) { # match key :/= val pairs if( match( $0, "[=:]") ) { # split split( $0, a, "[[:space:]]*[:|=][[:space:]]*" ) # trim gsub("^[[:space:]]*","",a[1]) gsub("^[[:space:]]*","",a[2]) # store if( ! fir ) { aas = aas "," a[1] ":" a[2]; } else { aas = aas a[1] ":" a[2]; } fir = 0; ++kc; } } } END { aas = aas "}"; print aas; if( kc ) exit 0; exit 1; }' }
over the hills and faraway