[U-Boot] [PATCH] common: cli_simple: Recursively parse variables
Nishanth Menon
nm at ti.com
Fri Dec 4 18:17:31 CET 2015
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 <nm at ti.com>
---
Testing with sandbox: http://pastebin.ubuntu.com/13672432/
common/cli_simple.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
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;
}
--
2.6.2.402.g2635c2b
More information about the U-Boot
mailing list