From: Wolfgang Denk Date: Wed, 12 Feb 2020 12:45:15 +0100 Subject: [PATCH] RFC: nvedit: support doing one (extra) expansion of the value in "env set" In-Reply-To: <2e076ba8-6ffe-66dc-ecb9-ebb62e47f414@prevas.dk> References: <20200205010812.20373-1-rasmus.villemoes@prevas.dk> <20200211163055.30A262403FE@gemini.denx.de> <2e076ba8-6ffe-66dc-ecb9-ebb62e47f414@prevas.dk> Message-ID: <20200212114516.08E26240057@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Rasmus, In message <2e076ba8-6ffe-66dc-ecb9-ebb62e47f414@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 ", 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.