From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] commands: setenv: support setenv dev.var=VAL syntax
Date: Tue, 15 Sep 2020 14:08:30 +0200 [thread overview]
Message-ID: <20200915120831.20549-1-a.fatoum@pengutronix.de> (raw)
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>
---
commands/setenv.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/commands/setenv.c b/commands/setenv.c
index 3cf769d24a68..a70a0de4cebc 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)
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2020-09-15 12:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 12:08 Ahmad Fatoum [this message]
2020-09-15 12:08 ` [PATCH 2/2] commands: setenv: allow use with hush shell Ahmad Fatoum
2020-09-18 9:01 ` [PATCH 1/2] commands: setenv: support setenv dev.var=VAL syntax Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200915120831.20549-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox