diff mbox series

[RFC,v1,14/21] cli: Modify run_command() to add hush 2021 as parser.

Message ID 20211231161327.24918-15-francis.laniel@amarulasolutions.com
State RFC
Delegated to: Tom Rini
Headers show
Series Modernize U-Boot shell | expand

Commit Message

Francis Laniel Dec. 31, 2021, 4:13 p.m. UTC
This commit then enables using, in code, run_command() while using hush 2021 as
parser.
It also enables the command run to be used by CLI user of hush 2021.

Signed-off-by: Francis Laniel <francis.laniel@amarulasolutions.com>
---
 common/cli.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Comments

Simon Glass Jan. 12, 2022, 8:03 p.m. UTC | #1
On Fri, 31 Dec 2021 at 09:14, Francis Laniel
<francis.laniel@amarulasolutions.com> wrote:
>
> This commit then enables using, in code, run_command() while using hush 2021 as
> parser.
> It also enables the command run to be used by CLI user of hush 2021.
>
> Signed-off-by: Francis Laniel <francis.laniel@amarulasolutions.com>
> ---
>  common/cli.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/common/cli.c b/common/cli.c
index 090677f7a0..46afa34b98 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -47,8 +47,21 @@  int run_command(const char *cmd, int flag)
 		hush_flags |= FLAG_CONT_ON_NEWLINE;
 	return parse_string_outer(cmd, hush_flags);
 #else /* HUSH_2021_PARSER */
-	/* Not yet implemented. */
-	return 0;
+	/*
+	 * Possible values for flags are the following:
+	 * FLAG_EXIT_FROM_LOOP: This flags ensures we exit from loop in
+	 * parse_and_run_stream() after first iteration while normal behavior,
+	 * i.e. when called from cli_loop(), is to loop infinitely.
+	 * FLAG_PARSE_SEMICOLON: Hush 2021 parses ';' and does not stop first
+	 * time it sees one. So, I think we do not need this flag.
+	 * FLAG_REPARSING: For the moment, I do not understand the goal of this
+	 * flag.
+	 * FLAG_CONT_ON_NEWLINE: This flag seems to be used to continue parsing
+	 * even when reading '\n' when coming from run_command(). In this case,
+	 * Hush 2021 reads until it finds '\0'. So, I think we do not need this
+	 * flag.
+	 */
+	return parse_string_outer(cmd, FLAG_EXIT_FROM_LOOP);
 #endif
 }