From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Fri, 01 Aug 2014 13:07:24 -0600 Subject: [U-Boot] [PATCH] pxe: Allow use of environment variables in append string In-Reply-To: <1406884903-24749-1-git-send-email-hdegoede@redhat.com> References: <1406884903-24749-1-git-send-email-hdegoede@redhat.com> Message-ID: <53DBE56C.9020308@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 08/01/2014 03:21 AM, Hans de Goede wrote: > Use run_command("setenv bootargs 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.