View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004880 | UBoot | U-Boot | public | 2021-10-04 16:30 | 2021-10-05 10:50 |
Reporter | derksen | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Target Version | fsimx8mm-Y2021.04 | Fixed in Version | fsimx8mm-Y2021.04 | ||
Summary | 0004880: cli_hush: Add support for indirect parameter expansion | ||||
Description | cli_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. ${!var} 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. Example: 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 | |||||