Say I did the following:
IFS=,
x="hello,hi,world"
y=$x
y
will have the string hello hi world
, so it's like y=$x
was replaced by:
y="hello hi world"
Now say I have the following script:
IFS=,
x="hello,hi,world"
if [ $x = "hello hi world" ]
then
echo "equal"
fi
When running the above script, I get the following error:
test.sh: line 3: [: too many arguments
I assume that I got this error because the statement if [ $x = "hello hi world" ]
was replaced by if [ hello hi world = "hello hi world" ]
and not by if [ "hello hi world" = "hello hi world" ]
upon execution.
So this means that the variable $x
was expanded in two different ways depending on the context it was in (one time it was expanded with double quotes, and another time it was expanded without double quotes).
Am I correct?