I know that MyVar="a b" ; [ $MyVar = "a b" ]
will signal an error because the resultant expansion is [ a b = "a b" ]
.
I tried to avoid that case:
$ MyVar="\"a b\""
$ [ $MyVar = "a b" ]
-bash: [: too many arguments
Why did I fail? Didn't it expand to [ "a b" = "a b" ]
?
I know there is a [[ ... ]]
form; I know I can write "$MyVar"
.
I am asking why is my approach ineffective.