> echo hihi> VAR='echo hi'> $VARhiWhy is the output of the above commands different?A similar thing occurs with single quotes:> VAR=echo 'hi'> $VAR> 'hi'
Why does bash variable expansion retain quotes?
bash;shell;quoting
The extra pair of quotes would be consumed only by an extra evaluation step. For example forced by eval:bash-4.2$ VAR='echo hi'bash-4.2$ $VARhibash-4.2$ eval $VARhiBut generally is a bad idea to put commands with parameters in one string. Use an array instead:bash-4.2$ VAR=(echo hi)bash-4.2$ ${VAR[@]}hi