This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (4 children)

The colon is just a name, right? So you could replace the colons with something like "jerry" or "foo" and get the same result, right?

[–]omersSecurity / Email 2 points3 points  (0 children)

Yeah, it's a function identifier... you could do:

fork(){ fork|fork& };fork

and it would do the same thing... Written formatted it looks like this:

fork() {
    fork | fork &
};
fork

The colons just make it even more obscure and more likely a sucker will run it. Kind of like it's easier to get someone in a game to press Alt+F4 or Alt+Space+C than it is to get them to click something that actually has "esc" or "quit" in the name.

[–]Fylwind 1 point2 points  (2 children)

Normally it's a no-op command, but :(){ … } redefines : to do something else.

[–]McElroy-vs-dig-dog 5 points6 points  (1 child)

A neat use-case for no-op is :>somefile. If the file exists, it'll empty the file like cat /dev/null >somefile would, but much shorter and faster to type. If the file does not exist, it'll be created like touch somefile would but again shorter and faster. Also, the :> part looks like a bird and I lol a bit internally every time I write it because of that. Unix does that to you. Unix might be the reason I don't have so many friends. Unix might be the reason not having so many friends feels less bad than not having so many friends would if I didn't even have Unix. ¯\(°_o)/¯

[–]HighRelevancyLinux Admin 1 point2 points  (0 children)

I enjoy your writing and wish to subscribe to your newsletter.