Todd,

People have posted valid reasons for using the shebang line, but
frankly I'm glad you brought this up, because I think a lot of
obsessive-compulsive programmers (myself included) write this when
it's really not necessary. If you're just learning ruby, writing a
one-off script, or writing a unit test script, it's perfectly fine to
leave it off. It takes time to write it and you usually have to jump
out of your editor to set the permissions to make it executable.

I think one of my favorite quotes, "A foolish consistency is the
hobgoblin of little minds", by Ralph Waldo Emerson applies here. Just
because it's useful in some situations isn't a reason to apply it to
all situations. If you're using a script/program that has the .rb file
extension and always going to be executed by typing "ruby", not
worrying about the shebang line saves you from:

1) Writing the shebang line
2) Deciding whether to use /usr/bin/ruby, /usr/bin/env ruby, or something else
3) Making the file executable
4) Obsessively-compulsively revisiting #2 next time you look at the file

Just my 2 cents.

-- Ben



On 5/11/07, Todd Burch <promos / burchwoodusa.com> wrote:
> I've written a few hundred scripts now, and not once have I ever coded a
> shebang line.  I'm writing on both Windows and the Mac (Tiger).
>
> Any time I'm kicking off a script from the Command Prompt or in Terminal
> on the Mac, I simply type
>
> ruby <name>.rb
>
> and it works just fine.
>
> So, when it comes down to it, what's the point of the shebang line?
>
> Todd
>
> --
> Posted via http://www.ruby-forum.com/.
>
>



-- 
Ben Atkin
ben / benatkin.com
http://www.benatkin.com/