Closed thorstenkampe closed 1 year ago
--format=lines
was added to give general flexibility like that. With some caveats on the format of the values, something like this might suffice, to give unique section_param=value items:
eval $(crudini --format=lines --get file.ini | sed 's/\[ \(.*\) \]/\1/; s/ = /=/; s/ /_/g')
This might be awkward/useful enough to warrant a --format=lines-sh option. Actually it probably makes sense for --format=sh to do that automatically when not presented with a section, as the current mode of just listing sections is not too useful.
Another interesting option is to have --format=bash output an associative array. While those can't be nested you could do something like:
declare -A filename_ini
filename_ini[section1|name1]=value11
filename_ini[section 2|name1]=value21
filename_ini[section 2|name2]='value2 2'
Which could be accessed like:
echo ${filename_ini[section 2|name2]}
Does
crudini
have support for reading the whole content (sections, keys) in one read with--format sh
?The documentation suggests I have to iterate over all sections in order to do that. That is inefficient and time consuming because the ini file is read (opened, closed) for each iteration...