aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJason Hobbs <jason.hobbs@calxeda.com>2011-06-29 11:25:17 -0500
committerJohn Rigby <john.rigby@linaro.org>2011-08-15 15:10:47 -0600
commit77b053841f59951c95c960d5a34aced4ba8733a0 (patch)
tree1ba361254d6de60eefb9b432c41a2558af4f6c81 /common
parent5849365c00f52867aef552196c1987fe15ff53f9 (diff)
common: add run_command2 for running simple or hush commands
Signed-off-by: Jason Hobbs <jason.hobbs@calxeda.com>
Diffstat (limited to 'common')
-rw-r--r--common/hush.c2
-rw-r--r--common/main.c46
2 files changed, 20 insertions, 28 deletions
diff --git a/common/hush.c b/common/hush.c
index 85a603071..940889b89 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -3217,7 +3217,7 @@ int parse_stream_outer(struct in_str *inp, int flag)
#ifndef __U_BOOT__
static int parse_string_outer(const char *s, int flag)
#else
-int parse_string_outer(char *s, int flag)
+int parse_string_outer(const char *s, int flag)
#endif /* __U_BOOT__ */
{
struct in_str input;
diff --git a/common/main.c b/common/main.c
index b97d89e58..3dedb728c 100644
--- a/common/main.c
+++ b/common/main.c
@@ -332,12 +332,7 @@ void main_loop (void)
int prev = disable_ctrlc(1); /* disable Control C checking */
# endif
-# ifndef CONFIG_SYS_HUSH_PARSER
- run_command (p, 0);
-# else
- parse_string_outer(p, FLAG_PARSE_SEMICOLON |
- FLAG_EXIT_FROM_LOOP);
-# endif
+ run_command2(p, 0);
# ifdef CONFIG_AUTOBOOT_KEYED
disable_ctrlc(prev); /* restore Control C checking */
@@ -382,12 +377,7 @@ void main_loop (void)
int prev = disable_ctrlc(1); /* disable Control C checking */
# endif
-# ifndef CONFIG_SYS_HUSH_PARSER
- run_command (s, 0);
-# else
- parse_string_outer(s, FLAG_PARSE_SEMICOLON |
- FLAG_EXIT_FROM_LOOP);
-# endif
+ run_command2(s, 0);
# ifdef CONFIG_AUTOBOOT_KEYED
disable_ctrlc(prev); /* restore Control C checking */
@@ -397,14 +387,8 @@ void main_loop (void)
# ifdef CONFIG_MENUKEY
if (menukey == CONFIG_MENUKEY) {
s = getenv("menucmd");
- if (s) {
-# ifndef CONFIG_SYS_HUSH_PARSER
- run_command(s, 0);
-# else
- parse_string_outer(s, FLAG_PARSE_SEMICOLON |
- FLAG_EXIT_FROM_LOOP);
-# endif
- }
+ if (s)
+ run_command2(s, 0);
}
#endif /* CONFIG_MENUKEY */
#endif /* CONFIG_BOOTDELAY */
@@ -1386,6 +1370,19 @@ int run_command (const char *cmd, int flag)
return rc ? rc : repeatable;
}
+int run_command2(const char *cmd, int flag)
+{
+#ifndef CONFIG_SYS_HUSH_PARSER
+ if (run_command(cmd, flag) == -1)
+ return 1;
+#else
+ if (parse_string_outer(cmd,
+ FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0)
+ return 1;
+#endif
+ return 0;
+}
+
/****************************************************************************/
#if defined(CONFIG_CMD_RUN)
@@ -1403,14 +1400,9 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
printf ("## Error: \"%s\" not defined\n", argv[i]);
return 1;
}
-#ifndef CONFIG_SYS_HUSH_PARSER
- if (run_command (arg, flag) == -1)
- return 1;
-#else
- if (parse_string_outer(arg,
- FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0)
+
+ if (run_command2(arg, flag) != 0)
return 1;
-#endif
}
return 0;
}