How to iterate over an array using indirect reference?

${!ARRAYNAME[@]} means “the indices of ARRAYNAME“. As stated in the bash man page since ARRAYNAME is set, but as a string, not an array, it returns 0. Here’s a solution using eval. #!/usr/bin/env bash ARRAYNAME=’FRUITS’ FRUITS=( APPLE BANANA ORANGE ) eval array=\( \${${ARRAYNAME}[@]} \) for fruit in “${array[@]}”; do echo ${fruit} done What you were … Read more

What does “level of indirection” mean in David Wheeler’s aphorism?

“Indirection” is using something that uses something else, in its broadest sense. So your example, using a pointer of a value instead of the value, fits this definition at one level. The pointer is the something and the value is the something else. Typically this is something larger in scope: Using a web site to … Read more

What does the quote “An extra level of indirection solves every problem” mean? [closed]

Generally it means that by increasing the level of abstraction one can make the problem easier to understand/resolve. Be careful with your abstractions though, the full quote at least as I heard it is, “You can solve every problem with another level of indirection, except for the problem of too many levels of indirection”.

Use placeholders in yaml

Context YAML version 1.2 user wishes to include variable placeholders in YAML have placeholders replaced with computed values, upon yaml.load be able to use placeholders for both YAML mapping keys and values Problem YAML does not natively support variable placeholders. Anchors and Aliases almost provide the desired functionality, but these do not work as variable … Read more

tech