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 <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). Rasmus