arm start.c: Make runtime function address calculation tolerant for more compilers
[barebox-mini2440.git] / commands / export.c
blob31259cc9b4ecef704074239976e9f0c193b9086f
1 /*
2 * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
4 * See file CREDITS for list of people who contributed to this
5 * project.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /**
22 * @file
23 * @brief export: Export an environment variable
26 #include <common.h>
27 #include <command.h>
28 #include <errno.h>
29 #include <environment.h>
31 static int do_export(struct command *cmdtp, int argc, char *argv[])
33 int i = 1;
34 char *ptr;
36 if (argc < 2)
37 return COMMAND_ERROR_USAGE;
39 while (i < argc) {
40 if ((ptr = strchr(argv[i], '='))) {
41 *ptr++ = 0;
42 setenv(argv[i], ptr);
44 if (export(argv[i])) {
45 printf("could not export: %s\n", argv[i]);
46 return 1;
48 i++;
51 return 0;
54 static const __maybe_unused char cmd_export_help[] =
55 "Usage: export <var>[=value]...\n"
56 "export an environment variable to subsequently executed scripts\n";
58 BAREBOX_CMD_START(export)
59 .cmd = do_export,
60 .usage = "export environment variables",
61 BAREBOX_CMD_HELP(cmd_export_help)
62 BAREBOX_CMD_END
64 /**
65 * @page export_command export: Export an environment variable
67 * Usage: export \<var>[=value]...
69 * Export an environment variable to subsequently executed scripts.