From: Rick DeNatale Date: 2008-02-12T21:06:01+09:00 Subject: Re: how to say # in ruby On 2/11/08, 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. Actually what that code does is: If the first line is a shebang if it doesn't contain 'ruby' somewhere extract the path which it seems to be wanting to run produce a fatal error else extract any arguments for the ruby command continue to process. end end So it is trying to avoid accidentially running, say a bash or perl script using the ruby interpreter. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/