Curly brackets converted to unicode in script

Is this a bash or wget issue?
GNU bash, version 4.4.0(1)-release (x86_64-slackware-linux-gnu)
GNU Wget 1.18 built on linux-gnu.

If I run wget -O file localhost/{2..4} from the command line, it will download pages 2 to 4 and concatenate them to file - which is what I want.

If I put this in a script, it works.

But if I add variables to the script wget -O file localhost/{$1..$2} and run script 2 4 wget tries to download localhost/%7B2..4%7D

I've worked around this, but it would be better to know why/how the curly brackets are being converted to their unicode equivalents so I can get it to work as required in the first place.

try:

wget -O file localhost/{${1}..${2}}

It's a bash feature:

echo {1..5}
1 2 3 4 5
set -- 1 5
echo {${1}..${2}}
{1..5}

You could use eval , but you should be very aware of its risks!

eval echo {${1}..${2}}
1 2 3 4 5
1 Like

Variables cannot be used in brace expansions. This is because of the parsing order. From a man bash:

Many thanks - eval is what I needed. Had to do the command substitution on the whole URL wget -O file $(eval echo localhost/{$1..$2}) , but it now works.

Should have known this because I've used eval before - must have had a mental block, but at least I've been prompted now to understand its use better.