The following script does not behave as I would have expected. Adding spaces around the '=' in the conditional made it perform how I wanted, but it got me thinking, what is it actually doing inside the conditional?
#!/bin/bash
S1='foo'
S2='bar'
if [ $S1=$S2 ];
then
echo "S1('$S1') is equal to S2('$S2')
fi
echo $S1
echo $S2
The output is:
S1('foo') is equal to S2('bar')
foo
bar
The contents of S1 and S2 don't change from what they are assigned, so the = doesn't perform an assignment.

