From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] pxe: Allow use of environment variables in append string
Date: Fri, 01 Aug 2014 13:07:24 -0600 [thread overview]
Message-ID: <53DBE56C.9020308@wwwdotorg.org> (raw)
In-Reply-To: <1406884903-24749-1-git-send-email-hdegoede@redhat.com>
On 08/01/2014 03:21 AM, Hans de Goede wrote:
> Use run_command("setenv bootargs <label->append>") so that environment
> variables (e.g. $console) can be used in append strings.
I'm slightly worried that this changes the semantics of the append line
in the PXE/extlinux config file. Namely, you suddenly have to start
worrying about escaping any $ signs or semi-colons etc..
> diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
> if (!localcmd)
> return -ENOENT;
>
> - if (label->append)
> - setenv("bootargs", label->append);
> + if (label->append) {
> + bootargs = malloc(strlen("setenv bootargs ") +
> + strlen(label->append) + 1);
> + if (!bootargs)
> + return 1;
Shouldn't this return a -ve error code for consistency with the other
pre-existing error case I quoted above.
> + strcpy(bootargs, "setenv bootargs ");
> + strcat(bootargs, label->append);
> + run_command(bootargs, 0);
Using whatever C function that the shell uses to expand variable
references in the command-line, rather than run_command(), would at
least avoid the issue of ; in label->append causing part of
label->append after the ; to be execututed as a separate command.
There would still be the issue of $ suddenly meaning something different.
next prev parent reply other threads:[~2014-08-01 19:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-01 9:21 [U-Boot] [PATCH] pxe: Allow use of environment variables in append string Hans de Goede
2014-08-01 19:07 ` Stephen Warren [this message]
2014-08-04 18:29 ` Hans de Goede
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=53DBE56C.9020308@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--cc=u-boot@lists.denx.de \
/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