title: bash if statement keeps changing second argument to literal string
body: <p>So I'm not sure why it's doing this. My if statement keeps interpreting the second variable as a literal string instead of a variable. Below is my exact code. </p>
  
  <pre><code>lights() {
    bulb1state=$(gatttool -b D8:6F:4B:09:AC:E6 --char-read -a 0x001b)
    echo $bulb1state
    bulb2state=$(gatttool -b DA:5A:4B:09:AC:E6 --char-read -a 0x001b)
    bulb3state=$(gatttool -b AC:E6:4B:07:39:E9 --char-read -a 0x0018)
    bulb4state=$(gatttool -b AC:E6:4B:08:40:50 --char-read -a 0x0018)
    offstate="Characteristic value/descriptor: 00 00 00 00"
    echo $bulb1state
    echo $offstate
    if [ "$offstate" = "$bulb1state" ]; then
      echo $bulb1state
      echo "bulb1 state = off"
      gatttool -b D8:6F:4B:09:AC:E6 --char-write -a 0x001b -n ff000000
      gatttool -b DA:5A:4B:09:AC:E6 --char-write -a 0x001b -n ff000000
      gatttool -b AC:E6:4B:07:39:E9 --char-write -a 0x0018 -n ff000000
      gatttool -b AC:E6:4B:08:40:50 --char-write -a 0x0018 -n ff000000
    fi
  }
  </code></pre>
  
  <p>My output:</p>
  
  <pre><code>&gt;lights
  Characteristic value/descriptor: 00 00 00 00
  Characteristic value/descriptor: 00 00 00 00
  Characteristic value/descriptor: 00 00 00 00
  </code></pre>
  
  <p>I don't understand why the last 2 echo statements are not displaying.</p>
  
  <p>Edits:
  There was a white space on bulb1state. This is good enough for me to find a work around but I'm still curious as why the second term of the if statement was being interpreted as a literal string when I used the "<code>=</code>" operator as opposed to the "<code>-eq</code>" operator. It also didn't matter which variable was first or second.</p>
  
  <p>after accounting for the whitespace at the end of bulb1state, using <code>-eq</code> instead of <code>=</code> yielded the following output:</p>
  
  <pre><code>&gt;lights
  Characteristic value/descriptor: 00 00 00 00
  #Characteristic value/descriptor: 00 00 00 00#
  #Characteristic value/descriptor: 00 00 00 00#
  bash: [[: Characteristic value/descriptor: 00 00 00 00: syntax error in expression (error token is "value/descriptor: 00 00 00 00")
  </code></pre>