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

Simon Glass sjg at chromium.org
Tue Feb 11 18:14:46 CET 2020


Hi Rasmus,

On Tue, 11 Feb 2020 at 08:38, Rasmus Villemoes
<rasmus.villemoes at prevas.dk> wrote:
>
> 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

Er, yes, sorry I was thinking of Makefiles.

Regards,
Simon


More information about the U-Boot mailing list