]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/cli.c
Fix spelling of "transferred".
[people/ms/u-boot.git] / common / cli.c
index ea6bfb3165678ad16b33dd43577f7e4f7f5c94b0..119d282bc240d82ba4cfcc050c1cb5c118709cb1 100644 (file)
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <cli.h>
 #include <cli_hush.h>
+#include <console.h>
 #include <fdtdec.h>
 #include <malloc.h>
 
@@ -36,8 +37,35 @@ int run_command(const char *cmd, int flag)
 
        return 0;
 #else
-       return parse_string_outer(cmd,
-                       FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP);
+       int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP;
+
+       if (flag & CMD_FLAG_ENV)
+               hush_flags |= FLAG_CONT_ON_NEWLINE;
+       return parse_string_outer(cmd, hush_flags);
+#endif
+}
+
+/*
+ * Run a command using the selected parser, and check if it is repeatable.
+ *
+ * @param cmd  Command to run
+ * @param flag Execution flags (CMD_FLAG_...)
+ * @return 0 (not repeatable) or 1 (repeatable) on success, -1 on error.
+ */
+int run_command_repeatable(const char *cmd, int flag)
+{
+#ifndef CONFIG_SYS_HUSH_PARSER
+       return cli_simple_run_command(cmd, flag);
+#else
+       /*
+        * parse_string_outer() returns 1 for failure, so clean up
+        * its result.
+        */
+       if (parse_string_outer(cmd,
+                              FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP))
+               return -1;
+
+       return 0;
 #endif
 }
 
@@ -75,9 +103,9 @@ int run_command_list(const char *cmd, int len, int flag)
         * is pretty rare.
         */
        rcode = cli_simple_run_command_list(buff, flag);
+#endif
        if (need_buff)
                free(buff);
-#endif
 
        return rcode;
 }
@@ -101,14 +129,14 @@ int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        return 1;
                }
 
-               if (run_command(arg, flag) != 0)
+               if (run_command(arg, flag | CMD_FLAG_ENV) != 0)
                        return 1;
        }
        return 0;
 }
 #endif
 
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
 bool cli_process_fdt(const char **cmdp)
 {
        /* Allow the fdt to override the boot command */
@@ -169,7 +197,7 @@ err:
         */
        hang();
 }
-#endif /* CONFIG_OF_CONTROL */
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 void cli_loop(void)
 {