From 6d53603c55a136309ad319b1e7b2716eb243ff2f Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 9 Aug 2023 18:48:22 +0200 Subject: [PATCH] CLI output pipes: Add CLICON_PIPETREE to any cli files, not just the first --- CHANGELOG.md | 4 ++++ apps/cli/cli_plugin.c | 9 ++++----- test/test_cli_pipe.sh | 7 ++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1403414..905d2984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,10 @@ Expected: October 2023 * Clarified clixon_cli command-line: `clixon_cli [options] [commands] [-- extra-options]` +### Corrected Bugs + +* Fixed: CLI output pipes: Add CLICON_PIPETREE to any cli files, not just the first + ## 6.3.0 29 July 2023 diff --git a/apps/cli/cli_plugin.c b/apps/cli/cli_plugin.c index a9afd4b1..a7eab9da 100644 --- a/apps/cli/cli_plugin.c +++ b/apps/cli/cli_plugin.c @@ -88,7 +88,6 @@ static int gen_parse_tree(clicon_handle h, char *name, parse_tree *pt, - char *pipetree, pt_head **php) { int retval = -1; @@ -102,9 +101,6 @@ gen_parse_tree(clicon_handle h, clicon_err(OE_UNIX, errno, "cligen_ph_prompt_set"); goto done; } - if (pipetree && - cligen_ph_pipe_set(ph, pipetree) < 0) - goto done; *php = ph; retval = 0; done: @@ -328,7 +324,7 @@ clispec_load_file(clicon_handle h, clicon_err(OE_UNIX, errno, "pt_new"); goto done; } - if (gen_parse_tree(h, name, ptnew, pipetree, &ph) < 0) + if (gen_parse_tree(h, name, ptnew, &ph) < 0) goto done; if (ph == NULL) goto done; @@ -344,6 +340,9 @@ clispec_load_file(clicon_handle h, if (cv) cv_free(cv); } + if (pipetree) /* Set if any file has it (never reset) */ + if (cligen_ph_pipe_set(ph, pipetree) < 0) + goto done; if (cligen_parsetree_merge(cligen_ph_parsetree_get(ph), NULL, pt) < 0){ clicon_err(OE_PLUGIN, errno, "cligen_parsetree_merge"); goto done; diff --git a/test/test_cli_pipe.sh b/test/test_cli_pipe.sh index 68bc8a74..afacd7b4 100755 --- a/test/test_cli_pipe.sh +++ b/test/test_cli_pipe.sh @@ -88,6 +88,12 @@ show("Show a particular state of the system"){ } EOF +# First file of mode does not have CLICON_PIPETREE, next have +cat < $clidir/before.cli +CLICON_MODE="default"; +dummy; +EOF + cat < $clidir/default.cli CLICON_MODE="default"; CLICON_PROMPT="%U@%H %W> "; @@ -110,7 +116,6 @@ EOF cat < $clidir/treeref.cli CLICON_MODE="treeref"; CLICON_PIPETREE="|mypipe"; - implicit("Show configuration"), cli_show_auto_mode("candidate", "xml", true, false); explicit("Show configuration"), cli_show_auto_mode("candidate", "xml", true, false);{ @|mypipe, cli_show_auto_mode("candidate", "xml", true, false);