diff options
| author | Matthew Cather | 2025-08-29 18:34:59 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2026-03-12 10:26:05 +0000 |
| commit | 74f6277aabffc943d026f406df57c22595134c42 (patch) | |
| tree | eb77f015a365c1610aa829c19f1cfc8192fc6332 | |
| parent | ccc171953852676a3a4e9086408db117563b1437 (diff) | |
| download | uci-master.tar.gz | |
Currently get commands return nothing to stdout on error in batch mode.
In practice, this makes them hard to use in scripts. If the caller
sends 4 gets and we only return 3 lines, the caller can not easily
determine which one did not work.
This changes the get command behavior in batch mode to always print
a new line, even on error. This allows the caller to determine which
get did not work. e.x. if the 3rd line is blank then the 3rd get
did not work.
Signed-off-by: Matthew Cather <mattbob4@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | cli.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -476,6 +476,9 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv) return 255; if (uci_lookup_ptr(ctx, &ptr, argv[1], true) != UCI_OK) { + if ((flags & CLI_FLAG_BATCH) && cmd == CMD_GET) + printf("\n"); + cli_perror(); return 1; } @@ -488,6 +491,9 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv) switch(cmd) { case CMD_GET: if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) { + if (flags & CLI_FLAG_BATCH) + printf("\n"); + ctx->err = UCI_ERR_NOTFOUND; cli_perror(); return 1; |