}
debug("Starting %s process...\n", __FUNCTION__);
-#if !defined(CONFIG_SYS_HUSH_PARSER)
- ret = builtin_run_command(s, 0);
-#else
- ret = parse_string_outer(s, FLAG_PARSE_SEMICOLON
- | FLAG_EXIT_FROM_LOOP);
-#endif
+ ret = run_command(s, 0);
if (ret < 0)
debug("Error.. %s failed\n", __FUNCTION__);
else
if (*line) {
debug ("** exec: \"%s\"\n",
line);
- if (builtin_run_command(line, 0) < 0) {
+ if (run_command(line, 0) < 0) {
rcode = 1;
break;
}
++next;
}
if (rcode == 0 && *line)
- rcode = (builtin_run_command(line, 0) >= 0);
+ rcode = (run_command(line, 0) >= 0);
}
#endif
free (cmd);
# endif /* CONFIG_AUTOBOOT_KEYED */
#endif /* CONFIG_BOOTDELAY >= 0 */
-/*
- * Return 0 on success, or != 0 on error.
- */
-int run_command(const char *cmd, int flag)
-{
-#ifndef CONFIG_SYS_HUSH_PARSER
- /*
- * builtin_run_command can return 0 or 1 for success, so clean up
- * its result.
- */
- if (builtin_run_command(cmd, flag) == -1)
- return 1;
-
- return 0;
-#else
- return parse_string_outer(cmd,
- FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP);
-#endif
-}
-
/****************************************************************************/
void main_loop (void)
if (len == -1)
puts ("<INTERRUPT>\n");
else
- rc = builtin_run_command(lastcommand, flag);
+ rc = run_command(lastcommand, flag);
if (rc <= 0) {
/* invalid command or not repeatable, forget it */
* the environment data, which may change magicly when the command we run
* creates or modifies environment variables (like "bootp" does).
*/
-
-int builtin_run_command(const char *cmd, int flag)
+static int builtin_run_command(const char *cmd, int flag)
{
cmd_tbl_t *cmdtp;
char cmdbuf[CONFIG_SYS_CBSIZE]; /* working copy of cmd */
return rc ? rc : repeatable;
}
+/*
+ * Run a command using the selected parser.
+ *
+ * @param cmd Command to run
+ * @param flag Execution flags (CMD_FLAG_...)
+ * @return 0 on success, or != 0 on error.
+ */
+int run_command(const char *cmd, int flag)
+{
+#ifndef CONFIG_SYS_HUSH_PARSER
+ /*
+ * builtin_run_command can return 0 or 1 for success, so clean up
+ * its result.
+ */
+ if (builtin_run_command(cmd, flag) == -1)
+ return 1;
+
+ return 0;
+#else
+ return parse_string_outer(cmd,
+ FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP);
+#endif
+}
+
/****************************************************************************/
#if defined(CONFIG_CMD_RUN)