title: Equality comparison not working in bash script despite echo showing variables are equal
body: <p>I need to determine that one value set locally in the script matches either one of two values stored on a git repo in a .txt file. I successfully retrieve these values and save them into variables <code>currentVersion</code> and <code>newVersion</code>. I also do this with <code>dispGitTime</code> and <code>gitMESSAGE</code>.</p>
  
  <p>What's weird is that these two comparisons are working as expected:</p>
  
  <pre><code>if [ "$dispGitTime" = "" ]; then dispGitTime=0; fi
  if [ ! "$gitMESSAGE" = "" ]; then clear; echo "$gitMESSAGE"; sleep "$dispGitTime"; fi
  </code></pre>
  
  <p>But these two comparisons are not working! <code>else</code> is always being called!</p>
  
  <pre><code>if [ "$currentVersion" = "$scriptVersion" ]; then
          upToDate="true"
          printf "\n%*s" $((COLS/2)) "This script is up-to-date!"; sleep 1
      elif [ "$newVersion" = "$scriptVersion" ]; then
          upToDate="true"
          printf "\n%*s" $((COLS/2)) "This script is up-to-date!"; sleep 1
  </code></pre>
  
  <p>The entire function for context:
  (see below for output of this function)</p>
  
  <pre><code>gitConfigs(){
          terminalPath=""; terminalPath=$(pwd)
          rm -rf ~/upt; mkdir ~/upt; cd ~/upt || return
  
          # clone repo or update it with git pull if it exists already
          (CMD_gitGet); wait
          cd "$terminalPath" || return
  
          # get config values from the master branch's properties.txt
          currentVersionLine=$(grep -n "_version " ~/upt/$gitName/properties.txt); currentVersion="${currentVersionLine##* }"; echo $currentVersion
          newVersionLine=$(grep -n "_newVersion " ~/upt/$gitName/properties.txt); newVersion="${newVersionLine##* }"; echo $newVersion
          gitMESSAGELine=$(grep -n "_gitMESSAGE " ~/upt/$gitName/properties.txt); gitMESSAGE="${gitMESSAGELine##* }"
          dispGitTimeLine=$(grep -n "_dispGitTime " ~/upt/$gitName/properties.txt); dispGitTime="${dispGitTimeLine##* }"
  
          echo $scriptVersion; sleep 2
  
          # set scriptTitle to match config, else use default
          if scriptTitle=$(grep -n "_scriptTitle " ~/upt/Android-Installer/properties.txt); then
              scriptTitle="${scriptTitle##* }"
          else scriptTitle="$scriptTitleDEF"; fi
  
          if [ "$currentVersion" = "$scriptVersion" ]; then
              upToDate="true"
              printf "\n%*s" $((COLS/2)) "This script is up-to-date!"; sleep 1
          elif [ "$newVersion" = "$scriptVersion" ]; then
              upToDate="true"
              printf "\n%*s" $((COLS/2)) "This script is up-to-date!"; sleep 1
          else
              upToDate="false"
              printf "\n\n\n\n\n%*s\n" $((COLS/2)) "This script: v$scriptVersion"
              printf "\n%*s\n" $((COLS/2)) "Latest version: v$currentVersion"
              printf "%*s\n" $((COLS/2)) "Version in progress: v$newVersion"
  
              printf "\n%*s" $((COLS/2)) "Update required..."; sleep 2
              #update
          fi
  
          # display gitMESSAGE if there is one
          if [ "$dispGitTime" = "" ]; then dispGitTime=0; fi
          if [ ! "$gitMESSAGE" = "" ]; then clear; echo "$gitMESSAGE"; sleep "$dispGitTime"; fi
      }
  </code></pre>
  
  <p>Ouput:</p>
  
  <pre><code>1.1.6-beta
  1.1.7-release
  1.1.7-release
  
  
  
  
  
                                              This script: v1.1.7-release
  
                                             Latest version: v1.1.6-beta
                                     Version in progress: v1.1.7-release
  
                                                       Update required...
  </code></pre>