View Issue Details

IDProjectCategoryView StatusLast Update
0004880UBootU-Bootpublic2021-10-05 10:50
Reporterderksen Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Target Versionfsimx8mm-Y2021.04Fixed in Versionfsimx8mm-Y2021.04 
Summary0004880: cli_hush: Add support for indirect parameter expansion
Descriptioncli_hush: Add support for indirect parameter expansion

Add indirect parameter expansion to the Hush Command Line Interface.
Like in bash, this is done by adding an exclamation mark in front of
a variable name.
Indirect expansion means that not the value of the variable itself is
returned, but the value is used as the name of a second variable, and
the value of that second variable is finally returned.
  setenv text_A foo
  setenv text_B bar
  setenv name text_B
  echo ${!name}
This will show "bar". The variable name has the content "text_B", so
this is used as the name of the variable to actually use. So in the
end, the content of variable text_B is returned, which is "bar".
This can be used to compute variable names. For example if you have a
variable mode that is set to either "A" or "B", then you can call
the appropriate text with
  setenv name text_$mode
  echo ${!name}
The first command constructs the name of the variable by using the
prefix "text_" and adding the content of variable mode. So name will
either be set to "text_A" or "text_B". This name is then used to
access the real variable. So if mode contains "A", the final output
is "foo", if it contains "B", the output is "bar".
Forum Link


There are no notes attached to this issue.