[Solved] Procd - config_foreach - how does section name evaluate?

I put together a small procd script that builds a command line from a config script to help me learn a bit more about procd under OpenWrt and kill another bird with the same stone by automating a common task.

Got it working ok with a single config. Changed logic a bit to config_foreach <function> $1 where $1 holds variable passed by command line, added a second config section, and that worked out as well. Soooo, I set up some shell aliases, and added the remaining sections to the config.

Here’s where the problem comes into play. For reference, the config structure is:

Config  wan
        option <name>  value
                .
                .
                .
config  br-lan
        option <name>  value
                .
                .
                .

I had hoped to use the section value (br-lan, wan, vpn0) to populate the interface name into the script generated command, but for some reason br-lan evaluates to section=cfg??????, while all the other sections evaluate properly - wan=wan, vpn0=vpn0.

I can work around it by adding an otherwise redundant option interface to the config, but really just would like to know why the - in br-lan breaks things.

1 Like
1 Like

Many thanks. I had figured out the - as the likely culprit, but couldn’t find anything in the devdocs, and didn’t really expect to find the answer in the userdocs. Not to mention I’m pretty well illiterate when it comes to UCI.

It just seemed intuitive to assume <type> would be interpreted as a string literal especially when, in it’s absence, the system will generate it’s own in the form cfg12345.

Thanks for the pointer to the “missing link”.

1 Like

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