Skip to contentSkip to conversation

cmd: env: Add `indirect` to indirectly set values

PATCH In review Samuel Dionne-Riel 3 participants 3 messages Dec 20, 2021 – Apr 8, 2022

lore
Share & tools
lore
#0 lore raw

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.

Cc Simon Glass <[email protected]>
Cc "Marek Behún" <[email protected]>
---
 cmd/Kconfig  |  4 ++++
 cmd/nvedit.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
cmd/Kconfig +4 -0
index 26d5707f75..e538e69a11 100644
@@ -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
#1 lore raw

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_mmc0 and similar are set appropriately.

A default value can be optionally provided.

Note: this acts on environment variables, not hush variables.

Quoted 7 lines
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

#2 lore raw
In reply to Samuel Dionne-Riel
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_mmc0 and similar are set appropriately.

Quoted 7 lines

A default value can be optionally provided.

Note: this acts on environment variables, not hush variables.

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