A cotação dupla $2 (se é onde o valor está) é a coisa correta a ser feita.
Se você está olhando para a saída de set -x , esteja ciente de que o shell pode adicionar várias cotações nessa saída. Essas citações extras não fazem parte dos dados.
Exemplo (em bash ):
var=--vars="service_name='someothername'"
printf 'var has value %s\n' "$var"
Isto irá produzir
var has value --vars=service_name='someothername'
mas a saída set -x será
$ set -x
$ var=--vars="service_name='someothername'"
+ var='--vars=service_name='\''someothername'\'''
$ printf 'var has value %s\n' "$var"
+ printf 'var has value %s\n' '--vars=service_name='\''someothername'\'''
var has value --vars=service_name='someothername'
Em pdksh no OpenBSD:
$ set -x
$ var=--vars="service_name='someothername'"
+ var=--vars=service_name='someothername'
$ printf 'var has value %s\n' "$var"
+ printf var has value %s\n --vars=service_name='someothername'
var has value --vars=service_name='someothername'
Em zsh :
$ set -x
$ var=--vars="service_name='someothername'"
+zsh:10> var='--vars=service_name='\''someothername'\'
$ printf 'var has value %s\n' "$var"
+zsh:11> printf 'var has value %s\n' '--vars=service_name='\''someothername'\'
var has value --vars=service_name='someothername'
Não se preocupe com essa cotação extra na saída de depuração. Basta usar sua variável com aspas duplas em torno dela e você ficará bem.