"uci set" vs. config_set vs uci_set vs. uci_set_state

I am writing a (posix) shell script that modifies config files located in /etc/config. I already understand how to use callbacks and config_foreach etc.

To perform the modifications, should I use:

  1. uci set (as explained in the documentation), or ...

  2. config_set (prominently documented in "Configuration in scripts" but then, as an afterthought, described as "arcane and buggy" and effectively deprecated), or ...

  3. uci_set (a thin wrapper around uci set, defined in uci.sh. "Configuration in scripts" suggests using this wrapper, but as I know that my config files are in /etc/config, then I think that this wrapper brings me no benefit.), or ...

  4. uci_set_state (also defined in uci.sh, but specifically modifies the contents of /var/state. Again, as my config files are in /etc/config, this wrapper brings me no benefit. Also, this says "uci state vars are deprecated" so possibly this function is also deprecated) ?

I think that option 1 (uci set) wins here. Is this the general consensus?


I concur. It works for me.

1 Like

uci_set is a higher level API implemented for completeness of functionality, so using it or not is mainly a question of own coding policy for combining different level APIs in one script.

uci batch and uci import were the actual deciding factors for me.

1 Like