fix lua binding include path
[project/uci.git] / cli.c
diff --git a/cli.c b/cli.c
index 1f08100d354f38c2f9ab93a3bc1ca1f69d97463e..9a4f8191075e0555de47563b69aba18e943d85de 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -202,8 +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))
+               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);
@@ -340,6 +343,11 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv)
        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);
@@ -432,6 +440,7 @@ static int uci_batch(void)
 {
        int ret = 0;
 
+       flags |= CLI_FLAG_BATCH;
        while (!feof(input)) {
                struct uci_element *e, *tmp;
 
@@ -446,6 +455,8 @@ static int uci_batch(void)
                        uci_unload(ctx, uci_to_package(e));
                }
        }
+       flags &= ~CLI_FLAG_BATCH;
+
        return 0;
 }