summaryrefslogtreecommitdiffstats
path: root/common/command.c
diff options
context:
space:
mode:
authorSascha Hauer <sha@pengutronix.de>2009-10-17 12:23:03 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2009-10-19 10:18:52 +0200
commit0ecf7f1aeb906e3b30500080fbc4e1d1b770f1a2 (patch)
treeab30c93958c0cc3b2191d564d36fc30ecdb221ee /common/command.c
parentcf996861d76fd7156c5bc096c68c62110f4531d7 (diff)
downloadbarebox-0ecf7f1aeb906e3b30500080fbc4e1d1b770f1a2.tar.gz
barebox-0ecf7f1aeb906e3b30500080fbc4e1d1b770f1a2.tar.xz
commands: add defines for command errors/success
This allows us to return COMMAND_ERROR_USAGE for a failed command which will then print the usage, a very common case for commands. Signed-off-by: Sascha Hauer <sha@pengutronix.de>
Diffstat (limited to 'common/command.c')
-rw-r--r--common/command.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/common/command.c b/common/command.c
index 24c2e2407f..52b9ee14ef 100644
--- a/common/command.c
+++ b/common/command.c
@@ -94,6 +94,7 @@ static int compare(struct list_head *a, struct list_head *b)
int execute_command(int argc, char **argv)
{
cmd_tbl_t *cmdtp;
+ int ret;
/* Look up command in command table */
if ((cmdtp = find_cmd(argv[0]))) {
@@ -103,7 +104,12 @@ int execute_command(int argc, char **argv)
return -1;
}
/* OK - call function to do the command */
- return cmdtp->cmd(cmdtp, argc, argv);
+ ret = cmdtp->cmd(cmdtp, argc, argv);
+ if (ret == COMMAND_ERROR_USAGE) {
+ u_boot_cmd_usage(cmdtp);
+ return COMMAND_ERROR;
+ }
+ return ret;
} else {
printf ("Unknown command '%s' - try 'help'\n", argv[0]);
return -1; /* give up after bad command */