I am new to shell script. I have a shell script which sources another file. Another file is just a file with name value pair. I have a confusion here.
test.dat
TEST_VARIABLE_PATH=/usr/project/workspace
script file (test_script.sh)
TEST_VARIABLE_PATH=
source test.dat
echo ${TEST_VARIABLE_PATH}
The above echo statement prints different values which makes me confused. In line 1, if I make
TEST_VARIABLE_PATH=/somepath/
, even I have sourced test.dat which has TEST_VARIABLE_PATH variable already set, echo is printing only
TEST_VARIABLE_PATH=/somepath/
where sourcing the file did not overwrite the variable.
Suppose If I have the line 1 as
TEST_VARIABLE_PATH=\`dirname $0\`/../
, source command overwrites and echo prints
TEST_VARIABLE_PATH=/usr/project/workspace
Why is this source behaving differently ? Please help me to understand.