mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-06-28 09:31:32 +00:00
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>
This commit is contained in:
parent
73671dad49
commit
1d43bfd2d5
2 changed files with 25 additions and 0 deletions
24
common/cli.c
24
common/cli.c
|
@ -41,6 +41,30 @@ int run_command(const char *cmd, int flag)
|
||||||
#endif
|
#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 run_command_list(const char *cmd, int len, int flag)
|
||||||
{
|
{
|
||||||
int need_buff = 1;
|
int need_buff = 1;
|
||||||
|
|
|
@ -271,6 +271,7 @@ int print_buffer(ulong addr, const void *data, uint width, uint count,
|
||||||
/* common/main.c */
|
/* common/main.c */
|
||||||
void main_loop (void);
|
void main_loop (void);
|
||||||
int run_command(const char *cmd, int flag);
|
int run_command(const char *cmd, int flag);
|
||||||
|
int run_command_repeatable(const char *cmd, int flag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a list of commands separated by ; or even \0
|
* Run a list of commands separated by ; or even \0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue