Skip to main content
2 of 8
added 392 characters in body
slm
  • 379.8k
  • 127
  • 793
  • 897

Change this line:

if [[ "$TEST" == "ON Master" ]];

To this:

if [ "$TEST" == "ON Master" ];

Details

The issue is the use of [[ .. ]]. The output is showing you the difference. Your value that you're getting for $STATUS is not simply "On Master". It most likely contains other characters, that are most likely not printable so are not being seen.

[[ .. ]]

++ echo On Master
+ TEST='On Master'
+ [[ On Master == \O\N\ \M\a\s\t\e\r ]]

[ .. ]

++ echo On Master
+ TEST='On Master'
+ '[' 'On Master' == 'ON Master' ']'

The use of double square brackets ([[ .. ]]) is discussed here on the TLDP Advanced Bash Scripting pages.

echo $STATUS

This line seems a little suspicious to me as well. I'd protect the contents of $STATUS by wrapping it in double quotes as well.

TEST=`echo "$STATUS"`

Also I'd drop the back ticks (\..``) and use the $( ... ) notation instead for executing this command. This change is just a best practice and isn't part of your issue though.

TEST=$(echo "$STATUS")
slm
  • 379.8k
  • 127
  • 793
  • 897