Bash script string interpolation leaves curly braces intact

bashshell-script

The request string in the example below interpolates version variable, but keeps the curly braces and I can't figure out why.

#!/bin/sh

version=2989
request="http://example.com/?version={$version}&therest"
echo "$request"

Result:

$ ~/script.sh
http://example.com/?version={2989}&therest

Environment:

$ echo $0
-zsh

Best Answer

The { is before $. It should be ${version} :)

Related Question