title: Why are my supposedly identical variables are seen as different by test in bash?
body: <p>My problem is that supposedly identical variables are seen as different by test, and a supposedly empty variable is seen as not empty. I have a file containing variables on two machines, and I'm trying to load the local variables, then load the remote variables, and check them for differences. It's part of a larger script, so i'm reducing the code down to a simpler form. The script is run from machine A. I think i'm misunderstanding something somewhere, but can't for the life of me work out what it is.</p>
  <p>Machine A <code>~/file.conf</code></p>
  <pre><code>version='1.0'
  path='/tmp/'
  </code></pre>
  <p>Machine B <code>~/file.conf</code></p>
  <pre><code>version='1.0'
  path=''
  </code></pre>
  <p>Machine A <code>script.sh</code></p>
  <pre><code>#!/bin/bash
  
  . ~/file.conf
  
  l_version=$version
  l_path=$path
  
  eval $(ssh -oBatchMode=yes -oConnectTimeout=5 -p 22 -tq user@machineb cat ~/file.conf) # load remote
  r_version=$version
  r_path=$path
  
  if [ -z $r_path ]; then
         echo &quot;r_path is empty!&quot;
  fi
  if [ $l_version != $r_version ]; then
         echo &quot;version is different!&quot;
  fi
  
  echo $l_version
  echo $l_path
  echo $r_version
  echo $r_path
  </code></pre>
  <p>Apologies if there are any syntax errors or anything, this is not the original code but should demonstrate my issue.</p>