summaryrefslogtreecommitdiffstats
path: root/commands/setenv.c
diff options
context:
space:
mode:
Diffstat (limited to 'commands/setenv.c')
-rw-r--r--commands/setenv.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/commands/setenv.c b/commands/setenv.c
index af4dd29ac4..99604c35c3 100644
--- a/commands/setenv.c
+++ b/commands/setenv.c
@@ -1,33 +1,30 @@
-/*
- * 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.
- *
- */
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: © 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
#include <common.h>
#include <command.h>
#include <errno.h>
#include <environment.h>
+#include <complete.h>
static int do_setenv(int argc, char *argv[])
{
+ char *val;
+ int ret;
+
if (argc < 2)
return COMMAND_ERROR_USAGE;
- setenv(argv[1], argv[2]);
+ val = parse_assignment(argv[1]);
+ if (val)
+ argv[2] = val;
+
+ if (argv[2])
+ ret = setenv(argv[1], argv[2]);
+ else
+ ret = unsetenv(argv[1]);
- return 0;
+ return ret ? COMMAND_ERROR : COMMAND_SUCCESS;
}
BAREBOX_CMD_HELP_START(setenv)
@@ -40,5 +37,6 @@ BAREBOX_CMD_START(setenv)
BAREBOX_CMD_DESC("set environment variable")
BAREBOX_CMD_OPTS("NAME [VALUE]")
BAREBOX_CMD_GROUP(CMD_GRP_ENV)
+ BAREBOX_CMD_COMPLETE(env_param_noeval_complete)
BAREBOX_CMD_HELP(cmd_setenv_help)
BAREBOX_CMD_END