Hi,
I got following cute little code at http://en.wikipedia.org/wiki/Fork_bomb :
:(){ :|:& };:
I tried to figure out how it does what it is intended to. Here are my insights:
: is a Bash Shell's no-op ( no operation ) literal, which can be used
as 'true' also.
| is pipe
& is to create processes in background
{ } is a code block
; is command separator
() is
First execute and verify the behaviour of :
[shell]$ :
Now execute this :
[shell]$ :(){ echo "in background"& }
redefines : to behave like a function which executes the command,
echo "in background"&
Now try this
[shell]$ :
in background
[2] 24399 ( some process id here )
Therefore,
:(){ :|:& };:
redefines : and calls once inside { } block and once after semicolon
;: , recursively!
I would like to know why,
[shell]$ :(){ echo "in background"& }
works?
[shell]$ :(){ echo "in background" } -- NOTE: no ampersand( & ) here!
does not work?
Did I miss any point in here?
-- tuxdna
tuxdna.blogspot.com
_______________________________________________
ilugd mailinglist -- [email protected]
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi
http://www.mail-archive.com/[email protected]/