Bash, bang!
Reviewing a vendor’s
code,
learnt about the use of exclamation mark (!) on a variable.
Bash 5 documentation states:
If the first character of parameter is an exclamation point (!), and parameter is not a nameref, it introduces a level of indirection. Bash uses the value formed by expanding the rest of parameter as the new parameter; this is then expanded and that value is used in the rest of the expansion, rather than the expansion of the original parameter. This is known as indirect expansion. (…)
Pretty neat!
Working example:
first=foo
second=$!first
echo $second
Outputs
foo