summaryrefslogtreecommitdiffstats
path: root/commands/exec.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-05 18:02:13 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-07-05 18:02:13 +0200
commit4b07af6730d2811363f158f5175138116038f7b9 (patch)
tree206044270884f80204a2da69e02ca3b6f5803185 /commands/exec.c
parentd08c60e9d77dc0f83946cd702d383451865e66dd (diff)
downloadbarebox-4b07af6730d2811363f158f5175138116038f7b9.tar.gz
barebox-4b07af6730d2811363f158f5175138116038f7b9.tar.xz
svn_rev_643
structure cleanup
Diffstat (limited to 'commands/exec.c')
-rw-r--r--commands/exec.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/commands/exec.c b/commands/exec.c
new file mode 100644
index 0000000000..2cba507519
--- /dev/null
+++ b/commands/exec.c
@@ -0,0 +1,44 @@
+#include <common.h>
+#include <command.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <linux/stat.h>
+#include <errno.h>
+#include <malloc.h>
+#include <xfuncs.h>
+
+#ifdef CONFIG_HUSH_PARSER
+#include <hush.h>
+#endif
+
+static int do_exec(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+ int i;
+ char *script;
+
+ if (argc < 2) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return 1;
+ }
+
+ for (i=1; i<argc; ++i) {
+ script = read_file(argv[i]);
+ if (!script)
+ return 1;
+
+ if (run_command (script, flag) == -1)
+ goto out;
+ free(script);
+ }
+ return 0;
+
+out:
+ free(script);
+ return 1;
+}
+
+U_BOOT_CMD_START(exec)
+ .maxargs = CONFIG_MAXARGS,
+ .cmd = do_exec,
+ .usage = "execute a script",
+U_BOOT_CMD_END