On 16 December 2014 at 16:28, Yousong Zhou <yszhou4t...@gmail.com> wrote: > On 15 December 2014 at 16:46, Yousong Zhou <yszhou4t...@gmail.com> wrote: >> >> Signed-off-by: Yousong Zhou <yszhou4t...@gmail.com> >> --- >> +static void uci_show_value(struct uci_option *o, bool quote) >> { >> struct uci_element *e; >> bool sep = false; >> >> switch(o->type) { >> case UCI_TYPE_STRING: >> - printf("%s\n", o->v.string); >> + if (quote) >> + uci_print_value(stdout, o->v.string); >> + else >> + printf("%s", o->v.string); >> + printf("\n"); >> break; >> case UCI_TYPE_LIST: >> uci_foreach_element(&o->v.list, e) { >> - printf("%s%s", (sep ? delimiter : ""), e->name); >> + printf("%s", (sep ? delimiter : "")); >> + uci_print_value(stdout, e->name); >> sep = true; >> } > > While `config_foreach` works okay with this change. I may note that > this will break usages like the following > > network=$(uci get sockd.instance0.internal_network) > status=$(ifstatus "$network") > > where option `internal_network` is of list type, thus the value will > be quoted resulting a call to ifstatus like the following. > > ifstatus "'vpn'" > > which is invalid of course. Anyway, I think `config_foreach` should > be used in such cases.
It's `config_list_foreach`, sorry for the typo. yousong > > Regards. > > yousong > > >> printf("\n"); >> @@ -190,13 +208,13 @@ static void uci_show_value(struct uci_option *o) >> } >> } _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel