From: Gerry Ford Date: 2008-02-12T10:30:52+09:00 Subject: Re: how to say # in ruby Tim Hunter wrote: > Robert Klemme wrote: > >> I'm not sure what you're at here. You posted code from the Ruby >> interpreter but the magical bit of shebang is done by the shell or OS >> not Ruby. > > Bear in mind that if the shell started the program and the program > specified on the shebang line wasn't the ruby interpreter, the code > quoted above doesn't run. > > Since it is running, somehow the ruby interpreter has been started and > given a file containing text that may or may not actually be Ruby code. > This could happen if you started ruby by explicitly executing the "ruby" > command, or if you're running on Windows where there is no shell to do > shebang interpreting for you. > > That bit of code inspects the shebang line and, if the word "ruby" > doesn't appear on the line, it tries to execute what it assumes is a > program. > > If you have access to Ruby on Windows, try it yourself. Thanks for your continued interest. I created 2 scripts: #! bla bla bla ruby puts "Hello World" __END__ # ruby test1.rb # ruby test1.rb >text55.txt 2>text56.txt This runs without objection. #! bla bla bla ginger puts "Hello World" __END__ # ruby test2.rb # ruby test2.rb >text55.txt 2>text56.txt I thought this would fail, but it didn't. I changed it to #! windows puts "Hello World" __END__ # ruby test2.rb # ruby test2.rb >text55.txt 2>text56.txt , and got: test2.rb:1: Can't exec windows (fatal) My point is that a comment should never be able to halt execution. cordially, -- -- Posted via http://www.ruby-forum.com/.