Config file consistency

Don't know if this is considered a bug or not.

[Note: I'm still running 19.7, this may have been addressed in 21.2.]

This is regarding the uci maintained files under /etc/config.

It is not required to update these files with uci. The documentation indicates it's quite OK to directly edit the files in /etc/config. However, there seems to be no consistency in how values are quoted: sometimes with no quotes, sometimes double quotes, sometimes single quotes. It also seems packages change what they do from version to version, but other reasons could give this appearance.

In digging into this I've re-read:

The documentation doesn't state a "correct" quote style to use. Except to say quotes must be used when the value contains a space. But it seems that single and double quotes are syntactically identical (unlike a shell where they have different symatics). Further, values are often quoted even when they don't have a space.

The reason for raising this and why I find it problematic is when upgrading packages.

During my most recent package updates, these messages were reported:

 * resolve_conffiles: Existing conffile /etc/config/luci is different from the conffile in the new package. The new conffile will be placed at /etc/config/luci-opkg.
 * resolve_conffiles: Existing conffile /etc/config/ucitrack is different from the conffile in the new package. The new conffile will be placed at /etc/config/ucitrack-opkg.

A common warning during an upgrade.

When I do a diff to find out the changes I find most lines don't match but it's only because of different quotes have been used.

I did further testing of changing values using the "uci" tool and found it (always?) puts values in single quotes (even when spaces are not present).

My question(s):

  1. Is there a reason why one quoting style isn't recommendedmandated?
  2. Given that uci puts all values in single quotes should that become the default?
  3. Is it considered a bug for config files to be inconsistent with what's produced by uci?


1 Like

Neither users nor developers have any substantial reason to care about that.
So, anything is considered fine as long as it is readable and works.

The initial config can also contain comments and spaces/tabs quite chaotically.
There's a customized diff command to simplify the comparison of UCI configs.

1 Like

Having two kinds of quotes is useful if the other kind of quote is needed in the value; for example option ssid "Joe's Diner". But that really isn't the best way to handle that situation, there should be a way to escape a quote mark.

1 Like

Thanks this was most helpful.

I found reading the code linked to in the response helpful especially the insight of using "uci export" to give an consistent format.

I suppose the need for the diff package is the reason this diff functionality isn't included by default.

@mk24 's also make sense.

Thanks everyone for the tips.

1 Like

The escape variant would be (following shell single quote escape semantics):

option ssid 'Joe'\''s Diner'

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