In Bash, dynamic variables can be created using indirect expansion.
How to create a dynamic variable name
In a CI container, there may be a need to delineate between different environment variable values using a prefix for a variable name.
|
|
Output:
|
|
In the example above, the secret
value is PROD_TOKEN
after expansion. Using indirect expansion, ${!secret}
references 123
.