2007-11-09 21:09:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief export: Export an environment variable
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <environment.h>
|
|
|
|
|
2011-12-21 13:18:57 +00:00
|
|
|
static int do_export(int argc, char *argv[])
|
2007-11-09 21:09:25 +00:00
|
|
|
{
|
|
|
|
int i = 1;
|
|
|
|
char *ptr;
|
|
|
|
|
2009-10-17 10:44:19 +00:00
|
|
|
if (argc < 2)
|
|
|
|
return COMMAND_ERROR_USAGE;
|
2007-11-09 21:09:25 +00:00
|
|
|
|
|
|
|
while (i < argc) {
|
|
|
|
if ((ptr = strchr(argv[i], '='))) {
|
|
|
|
*ptr++ = 0;
|
|
|
|
setenv(argv[i], ptr);
|
|
|
|
}
|
|
|
|
if (export(argv[i])) {
|
|
|
|
printf("could not export: %s\n", argv[i]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-31 20:37:48 +00:00
|
|
|
BAREBOX_CMD_HELP_START(export)
|
|
|
|
BAREBOX_CMD_HELP_USAGE("export <var>[=value]\n")
|
|
|
|
BAREBOX_CMD_HELP_SHORT("export an environment variable to subsequently executed scripts\n")
|
|
|
|
BAREBOX_CMD_HELP_END
|
2007-11-09 21:09:25 +00:00
|
|
|
|
2009-12-15 08:11:09 +00:00
|
|
|
BAREBOX_CMD_START(export)
|
2007-11-09 21:09:25 +00:00
|
|
|
.cmd = do_export,
|
|
|
|
.usage = "export environment variables",
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
BAREBOX_CMD_GROUP(CMD_GRP_ENV)
|
2009-12-15 08:11:09 +00:00
|
|
|
BAREBOX_CMD_HELP(cmd_export_help)
|
|
|
|
BAREBOX_CMD_END
|
2007-11-09 21:09:25 +00:00
|
|
|
|