I read the following in A User's Guide to the Z-Shell:
A synonym for ‘true’ is ‘:’; it’s often used in this form to give arguments which have side effects but which shouldn’t be used — something like
which is a common idiom in all Bourne shell derivatives. In the parameter expansion,
$paramis given the value value if it was empty before, and left alone otherwise. Since that was the only reason for the parameter expansion, you use
:to ignore the argument. Actually, the shell blithely builds the command line — the colon, followed by whatever the value of
$paramis, whether or not the assignment happened — then executes the command; it just so happens that ‘:’ takes no notice of the arguments it was given.
but I don't understand it. I get that
true, but there are two colons in the expression. As a minor question, why is this idiom used so much in all Bourne shell derivatives? What purpose does it serve?
Note: I am interested in what this idiom does in both bash and in zsh.