From patchwork Fri Dec 4 17:17:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 57707 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp681794lbb; Fri, 4 Dec 2015 09:17:45 -0800 (PST) X-Received: by 10.194.110.35 with SMTP id hx3mr21920750wjb.0.1449249465252; Fri, 04 Dec 2015 09:17:45 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id 202si7071364wmv.39.2015.12.04.09.17.44; Fri, 04 Dec 2015 09:17:45 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 893B94B67B; Fri, 4 Dec 2015 18:17:44 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nefJL0GtNMAl; Fri, 4 Dec 2015 18:17:44 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D7A904B65D; Fri, 4 Dec 2015 18:17:43 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 757F74B65D for ; Fri, 4 Dec 2015 18:17:40 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C5OyHn3I2c20 for ; Fri, 4 Dec 2015 18:17:40 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by theia.denx.de (Postfix) with ESMTPS id 077514B65A for ; Fri, 4 Dec 2015 18:17:36 +0100 (CET) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id tB4HHYIc014269; Fri, 4 Dec 2015 11:17:34 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id tB4HHYOe006320; Fri, 4 Dec 2015 11:17:34 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Fri, 4 Dec 2015 11:17:34 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id tB4HHXAJ017444; Fri, 4 Dec 2015 11:17:33 -0600 From: Nishanth Menon To: Tom Rini Date: Fri, 4 Dec 2015 11:17:31 -0600 Message-ID: <1449249451-8945-1-git-send-email-nm@ti.com> X-Mailer: git-send-email 2.6.2.402.g2635c2b MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] common: cli_simple: Recursively parse variables X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When we use the following in bootargs: v1=abc v2=123-${v1} echo $v2 we get 123-${v1} This is because we do not recursively check to see if v2 by itself has a hidden variable. Fix the same with recursive call Signed-off-by: Nishanth Menon --- Testing with sandbox: http://pastebin.ubuntu.com/13672432/ common/cli_simple.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) -- 2.6.2.402.g2635c2b _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/common/cli_simple.c b/common/cli_simple.c index 9c3d073d583b..63bda32c57e4 100644 --- a/common/cli_simple.c +++ b/common/cli_simple.c @@ -134,11 +134,17 @@ void cli_simple_process_macros(const char *input, char *output) envval = getenv(envname); /* Copy into the line if it exists */ - if (envval != NULL) - while ((*envval) && outputcnt) { - *(output++) = *(envval++); + if (envval != NULL) { + char finalval[CONFIG_SYS_CBSIZE], *f; + + cli_simple_process_macros(envval, + finalval); + f = finalval; + while ((*f) && outputcnt) { + *(output++) = *(f++); outputcnt--; } + } /* Look for another '$' */ state = 0; }