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.
Machine A ~/file.conf
version='1.0'
path='/tmp/'
Machine B ~/file.conf
version='1.0'
path=''
Machine A script.sh
#!/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 "r_path is empty!"
fi
if [ $l_version != $r_version ]; then
echo "version is different!"
fi
echo $l_version
echo $l_path
echo $r_version
echo $r_path
Apologies if there are any syntax errors or anything, this is not the original code but should demonstrate my issue.