As written, above works for me - but, as pointed out, you should change your test to -eq 0
.
For the syntax error near unexpected token problem - I will guess that your file contains embedded 'control codes', i.e. most likely a carriage return \r
.
Try:
cat -e ~/your_profile
see any non-printable characters? if so, remove them (cat
options may vary - check you manpage) or
od -c ~/your_profile