cmd: env: Add `indirect` to indirectly set values
PATCH 1/1 cmd: env: Add `indirect` to indirectly set values
This allows an ergonomic-enough approximation of ${!variable} expansion. This could be used the following way:
```
for target in ${boot_targets}; do
env indirect target_name target_name_${target}
# ...
done
```Assuming target_name_mmc0 and similar are set appropriately.
A default value can be optionally provided.
Note: this acts on environment variables, not hush variables.
--- cmd/Kconfig | 4 ++++ cmd/nvedit.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)
cmd/Kconfig +4 -0
@@ -508,6 +508,10 @@ config CMD_NVEDIT_EFI If enabled, we are allowed to set/print UEFI variables using "env" command with "-e" option without knowing details. +config CMD_NVEDIT_INDIRECT + bool "env indirect - Sets environment value from another" + default y + config CMD_NVEDIT_INFO bool "env info - print or evaluate environment information" help
cmd/nvedit.c +45 -0
63 lines not on this page · raw message
Signature · 6 lines
2.34.0 -- Samuel Dionne-Riel
Hi Samuel,
Quoted 10 lines · Samuel Dionne-Riel
This allows an ergonomic-enough approximation of ${!variable} expansion. This could be used the following way:
``` for target in ${boot_targets}; do env indirect target_name target_name_${target} # ... done ```
How is this different from:
for target in ${boot_targets}; do
env set target_name target_name_${target}
# ... done
Can you add a few more details?
Also needs some sort of update to doc/
Quoted 6 lines
Assuming
target_name_mmc0and similar are set appropriately.A default value can be optionally provided.
Note: this acts on environment variables, not hush variables.
Quoted 7 lines
Signed-off-by Samuel Dionne-Riel <[email protected]>Cc Simon Glass <[email protected]>Cc "Marek Behún" <[email protected]>--- cmd/Kconfig | 4 ++++ cmd/nvedit.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)
Regards,
Simon
Quoted 12 lines · Samuel Dionne-Riel
This allows an ergonomic-enough approximation of ${!variable} expansion. This could be used the following way:
``` for target in ${boot_targets}; do env indirect target_name target_name_${target} # ... done ```Assuming
target_name_mmc0and similar are set appropriately.
Quoted 7 lines
A default value can be optionally provided.
Note: this acts on environment variables, not hush variables.
Signed-off-by Samuel Dionne-Riel <[email protected]>Cc Simon Glass <[email protected]>Cc "Marek Behún" <[email protected]>
After making this not default y, applied to u-boot/master, thanks!
Signature · 1 line
Tom