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

Wolfgang Denk wd at denx.de
Wed Feb 12 12:45:15 CET 2020


Dear Rasmus,

In message <2e076ba8-6ffe-66dc-ecb9-ebb62e47f414 at prevas.dk> you wrote:
> 
> >> Well, there _are_ other ways...
> > 
> > Please do tell. How can I avoid code duplication and access a variable
> > whose name I generate by string concatenation/variable interpolation?
> 
> Btw., I also considered implementing this as a separate subcommand "env
> get <dest> <varname>", then I could do "env get result
> BOOT_${slot}_LEFT". That wouldn't be quite as powerful as "env set -E",
> but I think sufficient for my use case(s).

Sorry, but I still don;t understand what exactly your problem is.

Se previous message, or, slightly extended:

=> setenv BOOT_A_LEFT boot a left
=> setenv BOOT_B_LEFT boot b left
=> setenv BOOT_X_LEFT boot x left
=> setenv foo 'setenv result BOOT_${slot}_LEFT; printenv result; print $result'
=> slot=B
=> run foo
result=BOOT_B_LEFT
BOOT_B_LEFT=boot b left
=> slot=X
=> run foo
result=BOOT_X_LEFT
BOOT_X_LEFT=boot x left
=> slot=A
=> run foo
result=BOOT_A_LEFT
BOOT_A_LEFT=boot a left


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
No man knows what true happiness is until he gets married.  By  then,
of course, its too late.


More information about the U-Boot mailing list