implement ping using new network stack
[barebox-mini2440.git] / commands / setenv.c
blob257348f80afe6797b7b3ab5f1f3e39908e574865
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 setenv: Set an environment variables
26 #include <common.h>
27 #include <command.h>
28 #include <errno.h>
29 #include <environment.h>
31 static int do_setenv(struct command *cmdtp, int argc, char *argv[])
33 if (argc < 2)
34 return COMMAND_ERROR_USAGE;
36 setenv(argv[1], argv[2]);
38 return 0;
41 static const __maybe_unused char cmd_setenv_help[] =
42 "name value ...\n"
43 " - set environment variable 'name' to 'value ...'\n"
44 "setenv name\n"
45 " - delete environment variable 'name'\n";
48 BAREBOX_CMD_START(setenv)
49 .cmd = do_setenv,
50 .usage = "set environment variables",
51 BAREBOX_CMD_HELP(cmd_setenv_help)
52 BAREBOX_CMD_END
54 /**
55 * @page setenv_command setenv: set an environment variable
57 * Usage: setenv \<name> [\<value>]
59 * Set environment variable \<name> to \<value>. Without a given value, the
60 * environment variable will be deleted.
62 * @note This command is only available if the simple command line parser is
63 * in use. Within the hush shell \c setenv is not required.