From: Rasmus Villemoes Date: Tue, 11 Feb 2020 21:34:03 +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> <20200211163055.30A262403FE@gemini.denx.de> Message-ID: <2e076ba8-6ffe-66dc-ecb9-ebb62e47f414@prevas.dk> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 11/02/2020 22.20, Rasmus Villemoes wrote: > On 11/02/2020 17.30, Wolfgang Denk wrote: >>> This forces some scripts to needlessly duplicate logic and hardcode >>> assumptions. For example, in an A/B scheme with three variables >>> >>> BOOT_ORDER # Either "A B" or "B A" depending on which slot was last updated >>> BOOT_A_LEFT # 0..3 >>> BOOT_B_LEFT # 0..3 >>> >>> when one needs to determine the slot to boot from, one does something >>> like >> >> 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). Rasmus