The colon is a syntactic element that, essentially, does nothing, but returns true. It can be used whereever a command can be used.
It is sometimes needed where sh(1) requires a statement. E.g., this gives an error:
if [ "$a" = "" ] ; then
# comment out this part for now
# echo yes
else
echo no
fi
bash: syntax error near unexpected token `else'
Replacing the comment with a : makes it work:
if [ "$a" = "" ] ; then
# comment out this part for now
: echo yes
else
echo no
fi
It is rarely needed to explicitly use "exit 0" in the shell; in the absence of an exit statement, the shell script exits with the status of the last command, a shell script that just executes
/bin/false
will give an exit status 1:
$ echo $?
1
The colon is largely black magic, and I learned what little I know about it from experimentation.