[U-Boot] [PATCH 3/3] Add 'true' and 'false' commands

Peter Tyser ptyser at xes-inc.com
Sat Oct 17 00:36:27 CEST 2009


These commands are only enabled when the hush shell is enabled and can
be useful in scripts such as:

while true do
    echo "Booting OS...";
    run $bootcmd;
    echo "Booting OS failed";
    sleep 10;
done

Signed-off-by: Peter Tyser <ptyser at xes-inc.com>
---
This could be added as a hush builtin command if people don't want to
pollute the top-level help listing.  Its debatable if 'false' should
be added also, but I threw it in to be consistent.

 common/cmd_test.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/common/cmd_test.c b/common/cmd_test.c
index 3cdd07b..d886f89 100644
--- a/common/cmd_test.c
+++ b/common/cmd_test.c
@@ -149,3 +149,25 @@ U_BOOT_CMD(
 	"minimal test like /bin/sh",
 	"[args..]"
 );
+
+int do_false(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	return 1;
+}
+
+U_BOOT_CMD(
+	false,	CONFIG_SYS_MAXARGS,	1,	do_false,
+	"do nothing, unsuccessfully",
+	NULL
+);
+
+int do_true(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	return 0;
+}
+
+U_BOOT_CMD(
+	true,	CONFIG_SYS_MAXARGS,	1,	do_true,
+	"do nothing, successfully",
+	NULL
+);
-- 
1.6.2.1



More information about the U-Boot mailing list