I have a strange problem with bash that I cannot explain.
I created the script test.sh which contains the lines:
export TEST_HOME=`ls -d $HOME`
echo $TEST_HOME
if [ "$HOME" = "$TEST_HOME" ]
then
echo "Equal"
else
echo "Not equal"
fi
Now if I source test.sh:
$ . test.sh
the output is
/home/sven
Not equal
However, if I make it executable and run it as a normal script:
$ test.sh
the output is
/home/sven
Equal
Any explanation how this behavior is explained? I am using RedHat 5.
Best regards,
Sven