X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=cli.c;h=305d9fed4b3a83a3118c573b47da51f6bf144313;hp=5a260ef44907f87ce412b84ea95d043cdc0a042f;hb=43124956bc9c1083e476f6cadaedf27b7788d004;hpb=563f8dd6f0eb56780a00f5856bf7fcf40e39d845 diff --git a/cli.c b/cli.c index 5a260ef..305d9fe 100644 --- a/cli.c +++ b/cli.c @@ -187,13 +187,7 @@ static int package_cmd(int cmd, char *tuple) return 1; } - if (ptr.o) - e = &ptr.o->e; - else if (ptr.s) - e = &ptr.s->e; - else - e = &ptr.p->e; - + e = ptr.last; switch(cmd) { case CMD_CHANGES: uci_show_changes(ptr.p); @@ -208,6 +202,11 @@ static int package_cmd(int cmd, char *tuple) uci_export(ctx, stdout, ptr.p, true); break; case CMD_SHOW: + if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) { + ctx->err = UCI_ERR_NOTFOUND; + cli_perror(); + return 1; + } switch(e->type) { case UCI_TYPE_PACKAGE: uci_show_package(ptr.p); @@ -341,15 +340,14 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv) if (ptr.value && (cmd != CMD_SET) && (cmd != CMD_ADD_LIST) && (cmd != CMD_RENAME)) return 1; - if (ptr.o) - e = &ptr.o->e; - else if (ptr.s) - e = &ptr.s->e; - else - e = &ptr.p->e; - + e = ptr.last; switch(cmd) { case CMD_GET: + if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) { + ctx->err = UCI_ERR_NOTFOUND; + cli_perror(); + return 1; + } switch(e->type) { case UCI_TYPE_SECTION: printf("%s\n", ptr.s->type); @@ -366,10 +364,10 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv) ret = uci_rename(ctx, &ptr); break; case CMD_REVERT: - ret = uci_revert(ctx, &ptr.p, ptr.section, ptr.option); + ret = uci_revert(ctx, &ptr); break; case CMD_SET: - ret = uci_set(ctx, ptr.p, ptr.section, ptr.option, ptr.value, NULL); + ret = uci_set(ctx, &ptr); break; case CMD_ADD_LIST: ret = uci_add_list(ctx, &ptr); @@ -482,7 +480,8 @@ static int uci_cmd(int argc, char **argv) cmd = CMD_RENAME; else if (!strcasecmp(argv[0], "revert")) cmd = CMD_REVERT; - else if (!strcasecmp(argv[0], "del")) + else if (!strcasecmp(argv[0], "del") || + !strcasecmp(argv[0], "delete")) cmd = CMD_DEL; else if (!strcasecmp(argv[0], "import")) cmd = CMD_IMPORT;