zazenergy/Cthulhu — pull request #1 by jayed (2012-07-11 05:16:21+00:00)
Title: Add a hashbang (which only works for operating systems other than Windows).

A hashbang line tells the shell what program to use to execute the rest of the script. So instead of typing "ruby cthulhu.rb", you could just type "cthulhu.rb". (Though you still *could* type "ruby cthulhu.rb" if you felt like it.) It's never mandatory, but it's almost always a nice touch.

Wikipedia has a particularly thorough article about the practice and history of the hashbang line. http://en.wikipedia.org/wiki/Shebang_(Unix)

The tl;dr version is that since # indicates a comment in most computer languages, if you run this script the "ruby cthulhu.rb" way, the first line will just be ignored. If, however, you run it the new way, your shell (which is probably bash) will see #! on the first line and realize that the rest of the line contains instructions on how to execute the rest of your script. '/usr/bin/env' returns the full operating system path of 'ruby' (since we typed "/usr/bin/env ruby" that is; if it was "/usr/bin/env python" it would return the full path to the python executable if it could be found). So the first line will be be seen by bash as something like "#!/usr/bin/ruby" and it will feed the rest of your ruby script directly to the ruby interpreter.

(And congratulations!)