Uci: option vs list detection

I am trying to automate some configuration and want to detect if a configuration changes from a single value to a list or the other way. Using a wrong operation on a configuration parameter can lead to unexpected results in the future if I assume a parameter type based on the current config.
I.e. a specific parameter is an option at this time and I use uci set on it. In the future, it can changes to a list and I will need to use add_list: using set on a list corrupts config.
Is there a way besides using grep?

If you use the shell api (config_load, config_get etc.) you can use this:

config_get list_length "$sectionid" "${optionname}_LENGTH"
if [ -n "$list_length" ]; then
    echo "Option $optionname of section $sectionid is a list option"
1 Like

What is sectionid? I tried using nlbwmon.@nlbwmon[0], but it did not like it.

Its an internal random ID in the form cfgXXXXXX. You can obtain it using config_foreach

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.