Hacker News new | ask | show | jobs
by OJFord 846 days ago
> This works because the `:` is a way to set a label, and it implicitly returns 0. It's just a weird wrinkle of the language.

Do you have a source for that? I thought it was just POSIX built-in for true. Like `.` vs. `source`. What's a label in this context anyway?

3 comments

Hah, yeah I was completely wrong on that! Should have fact checked myself. That's a falsehood I absorbed at some point and didn't question.
Well there's a blog post idea for you, sounds primed for the front page already - Falsehoods Programmers Believe About Colons...
: is the prefix for labels in DOS batch files.
No need to ask for a source. The word "label" in the POSIX shell documentation only occurs in the description of `case`, and it doesn't happen in the manual page for bash, dash, zsh, etc.
Equally surprised. I know ':' is a label in sed, but labels in (ba)sh, I'm not aware. If it's indeed a label, is there a goto?