From: Rasmus Villemoes Date: Tue, 11 Feb 2020 15:38:40 +0000 Subject: [PATCH] RFC: nvedit: support doing one (extra) expansion of the value in "env set" In-Reply-To: References: <20200205010812.20373-1-rasmus.villemoes@prevas.dk> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 05/02/2020 18.59, Simon Glass wrote: > Hi Rasmus, > >> This has been lightly tested in the sandbox. I'll add some proper unit >> tests, update the help texts and try to handle the Kconfig issue if >> this is something that might be accepted. >> >> Signed-off-by: Rasmus Villemoes >> --- >> cmd/nvedit.c | 17 ++++++++++++++++- >> 1 file changed, 16 insertions(+), 1 deletion(-) > > Seems OK to me. Thanks. I'll go ahead and write some tests. > I suppose we don't want to implement bash's nested > expansion? ${var${suffix}} It's not that easy to implement inside-out expansion, one needs to juggle a lot of temporary buffers. So I went with the rather simple one-extra-pass, which can mostly achieve the same things (although perhaps the script needs to do a few extra steps). Out of curiosity, what bash version supports the above? $ echo $BASH_VERSION 4.4.20(1)-release $ foo_a=3 $ foo_b=7 $ x=a $ echo ${foo_${x}} bash: ${foo_${x}}: bad substitution however, this variant is supported: $ var=foo_$x $ echo ${var} foo_a $ echo ${!var} 3 > Regards, > Simon > -- Rasmus Villemoes Software Developer Prevas A/S Hedeager 3 DK-8200 Aarhus N +45 51210274 rasmus.villemoes at prevas.dk www.prevas.dk