[U-Boot] [PATCH] pxe: Allow use of environment variables in append string
Stephen Warren
swarren at wwwdotorg.org
Fri Aug 1 21:07:24 CEST 2014
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.
More information about the U-Boot
mailing list