I have a question regarding bash syntax. The bash manual, in section 3.5, says this:
The order of expansions is: brace expansion; tilde expansion,
parameter and variable expansion, arithmetic expansion, and command
substitution (done in a left-to-right fashion); word splitting; and
filename expansion.
Here’s the link: https://www.gnu.org/software/bash/manual/bash.html#Shell-Expansions
Now, these commands do what I expect:
$ echo 0 +{1..5}
0 +1 +2 +3 +4 +5
$ echo $((0 +1 +2 +3 +4 +5))
15
So I figured that this command should yield the same result as the second:
echo $((0 +{1..5}))
However, instead I get this error:
bash: 0 +{1..5}: syntax error: operand expected (error token is "{1..5}")
Why is this? Shouldn’t it first do the brace expansion inside and then evaluate the arithmetic expansion like in the second command?
Note: I’m not trying to do anything in particular. I’m just trying to understand how bash works.