[RFC PATCH v3 20/23] cli: hush_2021: Enable if keyword
Francis Laniel
francis.laniel at amarulasolutions.com
Fri Apr 1 01:27:13 CEST 2022
Adds support for "if then else" construct both for command line interface and
through run_command().
Signed-off-by: Francis Laniel <francis.laniel at amarulasolutions.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
common/cli_hush_upstream.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 2d1c892738..9c6df37149 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -3951,7 +3951,6 @@ static void debug_print_tree(struct pipe *pi, int lvl)
[PIPE_OR ] = "OR" ,
[PIPE_BG ] = "BG" ,
};
-#ifndef __U_BOOT__
static const char *RES[] = {
[RES_NONE ] = "NONE" ,
# if ENABLE_HUSH_IF
@@ -3981,7 +3980,6 @@ static void debug_print_tree(struct pipe *pi, int lvl)
[RES_XXXX ] = "XXXX" ,
[RES_SNTX ] = "SNTX" ,
};
-#endif /* !__U_BOOT__ */
static const char *const CMDTYPE[] = {
"{}",
"()",
@@ -3999,10 +3997,8 @@ static void debug_print_tree(struct pipe *pi, int lvl)
lvl*2, "",
pin,
pi->num_cmds,
-#ifdef __U_BOOT__
(IF_HAS_KEYWORDS(pi->pi_inverted ? "! " :) ""),
RES[pi->res_word],
-#endif /* !__U_BOOT__ */
pi->followup, PIPE[pi->followup]
);
prn = 0;
@@ -9792,6 +9788,7 @@ static NOINLINE int run_pipe(struct pipe *pi)
rcode = 1; /* exitcode if redir failed */
#ifndef __U_BOOT__
if (setup_redirects(command, &squirrel) == 0) {
+#endif /* !__U_BOOT__ */
debug_printf_exec(": run_list\n");
//FIXME: we need to pass squirrel down into run_list()
//for SH_STANDALONE case, or else this construct:
@@ -9800,10 +9797,11 @@ static NOINLINE int run_pipe(struct pipe *pi)
//and in SH_STANDALONE mode, "find" is not execed,
//therefore CLOEXEC on saved fd does not help.
rcode = run_list(command->group) & 0xff;
+#ifndef __U_BOOT__
}
restore_redirects(squirrel);
- IF_HAS_KEYWORDS(if (pi->pi_inverted) rcode = !rcode;)
#endif /* !__U_BOOT__ */
+ IF_HAS_KEYWORDS(if (pi->pi_inverted) rcode = !rcode;)
debug_leave();
debug_printf_exec("run_pipe: return %d\n", rcode);
return rcode;
@@ -10322,12 +10320,12 @@ static int run_list(struct pipe *pi)
break;
if (G_flag_return_in_progress == 1)
break;
+#endif /* !__U_BOOT__ */
IF_HAS_KEYWORDS(rword = pi->res_word;)
debug_printf_exec(": rword=%d cond_code=%d last_rword=%d\n",
rword, cond_code, last_rword);
-#endif /* !__U_BOOT__ */
sv_errexit_depth = G.errexit_depth;
if (
#if ENABLE_HUSH_IF
--
2.25.1
More information about the U-Boot
mailing list