arm start.c: Make runtime function address calculation tolerant for more compilers
[barebox-mini2440.git] / commands / exec.c
blob5f093b7b388e4ccfacde369013749ce6a7911de0
1 /*
2 * exec.c - execute scripts
4 * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
6 * See file CREDITS for list of people who contributed to this
7 * project.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <common.h>
24 #include <command.h>
25 #include <fs.h>
26 #include <fcntl.h>
27 #include <linux/stat.h>
28 #include <errno.h>
29 #include <malloc.h>
30 #include <xfuncs.h>
32 static int do_exec(struct command * cmdtp, int argc, char *argv[])
34 int i;
35 char *script;
37 if (argc < 2)
38 return COMMAND_ERROR_USAGE;
40 for (i=1; i<argc; ++i) {
41 script = read_file(argv[i]);
42 if (!script)
43 return 1;
45 if (run_command (script, flag) == -1)
46 goto out;
47 free(script);
49 return 0;
51 out:
52 free(script);
53 return 1;
56 BAREBOX_CMD_START(exec)
57 .cmd = do_exec,
58 .usage = "execute a script",
59 BAREBOX_CMD_END