diff options
author | Thomas Betker <thomas.betker@freenet.de> | 2014-06-05 20:07:57 +0200 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-06-11 16:25:47 -0400 |
commit | 1d43bfd2d54240c18ec6bfd68a57349cae839f13 (patch) | |
tree | b7d4eecf0998091adaa1bef9cc956ab98851a98c /common/cli.c | |
parent | 73671dad49bf2368959b7bf0e30ba931ea95565c (diff) | |
download | u-boot-imx-1d43bfd2d54240c18ec6bfd68a57349cae839f13.zip u-boot-imx-1d43bfd2d54240c18ec6bfd68a57349cae839f13.tar.gz u-boot-imx-1d43bfd2d54240c18ec6bfd68a57349cae839f13.tar.bz2 |
Add run_command_repeatable()
run_command() returns 0 on success and 1 on error. However, there are some
invocations which expect 0 or 1 for success (not repeatable or repeatable)
and -1 for error; add run_command_repeatable() for this purpose.
Signed-off-by: Thomas Betker <thomas.betker@rohde-schwarz.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/cli.c')
-rw-r--r-- | common/cli.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/common/cli.c b/common/cli.c index ea6bfb3..272b028 100644 --- a/common/cli.c +++ b/common/cli.c @@ -41,6 +41,30 @@ int run_command(const char *cmd, int flag) #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 +} + int run_command_list(const char *cmd, int len, int flag) { int need_buff = 1; |