title: Why equal to operator does not work if it is surrounded by space?
body: <p>I tried the following script</p>
  
  <pre><code>#!/bin/bash
  var1="Test 1" 
  var2="Test 2"
  if [ "$var1"="$var2" ] 
    then 
      echo "Equal" 
    else 
      echo "Not equal"
  fi
  </code></pre>
  
  <p>It gave me <code>Equal</code>. Although it should have printed <code>Not equal</code></p>
  
  <p>Only when I inserted space around <code>=</code> it worked as intended</p>
  
  <pre><code>if [ "$var1" = "$var2" ] 
  </code></pre>
  
  <p>and printed <code>Not equal</code></p>
  
  <p>Why is it so? Why <code>"$var1"="$var2"</code> is not same as <code>"$var1" = "$var2"</code>? </p>
  
  <p>Moreover, when I wrote <code>if [ "$var1"= "$var2" ]</code>, it gave</p>
  
  <pre><code>line 4: [: Test 1=: unary operator expected
  </code></pre>
  
  <p>What does it it mean? How come its expecting unary operator?</p>