How to use Bash substitution in a variable declaration
Some of you may have read the aforementioned question but I have been left with more questions than answer. I tried googling how bash tokenizing -> expansion works in detail but did not find the right answers.
Let's look at simple example:
q="www"
e=$q{.,.,.}
echo $e
#outputs: www{.,.,.}
Now this does not work as I would expect. Especially since echo $q{.,.,.} outputs www. www. www. as I would expect. There have been some sugestions in the first SO question to write stuff like set $q{.,.,.,1} & s="$@" & echo $s
This does work in the terminal but for some reasons when entered in a .sh script it outputs www{.,.,.}
Why is there a different behaviour between the script and the terminal and how to make sure to trigger the expansion?
Also, why does q=* trigger pathname expansion but q={.,.,.} does not trigger braces expansion?