summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-09-15 14:08:30 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-09-18 11:01:02 +0200
commitfbf145dc86832846465a317619dd4d61af3897b3 (patch)
tree7ce94c6f6f207074966dd41ab875deff7a757970 /commands
parent60e7290cd6bca70edd9b66f5fb732ea604d3ce63 (diff)
downloadbarebox-fbf145dc86832846465a317619dd4d61af3897b3.tar.gz
barebox-fbf145dc86832846465a317619dd4d61af3897b3.tar.xz
commands: setenv: support setenv dev.var=VAL syntax
In preparation for making setenv selectable under CONFIG_SHELL_HUSH, allow a `setenv dev.var=VAL syntax`: - makes command use less surprising for hush users - allows seamless integration with current device parameter complete While at it, propagate setenv's return code to the calling shell. 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/setenv.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/commands/setenv.c b/commands/setenv.c
index 3cf769d24a..a70a0de4ce 100644
--- a/commands/setenv.c
+++ b/commands/setenv.c
@@ -8,12 +8,20 @@
static int do_setenv(int argc, char *argv[])
{
+ char *equal;
+
if (argc < 2)
return COMMAND_ERROR_USAGE;
- setenv(argv[1], argv[2]);
+ equal = strrchr(argv[1], '=');
+ if (equal) {
+ equal[0] = '\0';
+ if (equal[1])
+ argv[2] = &equal[1];
+ }
+
- return 0;
+ return setenv(argv[1], argv[2]) ? COMMAND_ERROR : COMMAND_SUCCESS;
}
BAREBOX_CMD_HELP_START(setenv)