summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-09-15 14:08:31 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-09-18 11:01:19 +0200
commit932481a005cc7b2933791a349a312af0149b6c94 (patch)
treef2ad8701e842a301c97cffcfa0c40539aa42c0d9 /commands
parentfbf145dc86832846465a317619dd4d61af3897b3 (diff)
downloadbarebox-932481a005cc7b2933791a349a312af0149b6c94.tar.gz
barebox-932481a005cc7b2933791a349a312af0149b6c94.tar.xz
commands: setenv: allow use with hush shell
setenv was so far restricted to the simple shell, because with hush, users could just do dev.var=VAL for setting variables in the environment. The hush syntax doesn't allow for setting all kinds of environment variables though, e.g. 5c00a000.tamp@5c00a000:reboot-mode.of.param can't be set with hush, because of the special characters. It could still be read by using the ${variable} syntax though. Allow setting these variables by making the setenv command generally available. The default is chosen to be 'y', because the command is deemed small and useful enough to have it there by default. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/Kconfig13
-rw-r--r--commands/Makefile2
-rw-r--r--commands/setenv.c2
3 files changed, 16 insertions, 1 deletions
diff --git a/commands/Kconfig b/commands/Kconfig
index 3789f33c3b..1399f04d8b 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -718,6 +718,19 @@ config CMD_SAVEENV
/dev/env0. Note that envfs can only handle files, directories are being
skipped silently.
+config CMD_SETENV
+ tristate
+ default y
+ depends on !CONFIG_SHELL_NONE
+ prompt "setenv"
+ help
+ Set environment variable
+
+ Usage: setenv NAME [VALUE]
+
+ Set environment variable NAME to VALUE.
+ If VALUE is ommitted, then the variable is deleted.
+
# end Environment commands
endmenu
diff --git a/commands/Makefile b/commands/Makefile
index 01082de44c..6cc4997cc5 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -41,7 +41,7 @@ obj-$(CONFIG_CMD_FLASH) += flash.o
obj-$(CONFIG_CMD_MEMINFO) += meminfo.o
obj-$(CONFIG_CMD_TIMEOUT) += timeout.o
obj-$(CONFIG_CMD_READLINE) += readline.o
-obj-$(CONFIG_SHELL_SIMPLE) += setenv.o
+obj-$(CONFIG_CMD_SETENV) += setenv.o
obj-$(CONFIG_CMD_EXPORT) += export.o
obj-$(CONFIG_CMD_PRINTENV) += printenv.o
obj-$(CONFIG_CMD_SAVEENV) += saveenv.o
diff --git a/commands/setenv.c b/commands/setenv.c
index a70a0de4ce..ad26770655 100644
--- a/commands/setenv.c
+++ b/commands/setenv.c
@@ -5,6 +5,7 @@
#include <command.h>
#include <errno.h>
#include <environment.h>
+#include <complete.h>
static int do_setenv(int argc, char *argv[])
{
@@ -34,5 +35,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