[PATCH] RFC: nvedit: support doing one (extra) expansion of the value in "env set"

Rasmus Villemoes rasmus.villemoes at prevas.dk
Tue Feb 11 16:38:40 CET 2020


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 <rasmus.villemoes at prevas.dk>
>> ---
>>  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


More information about the U-Boot mailing list