From: Tim Hunter Date: 2008-02-07T05:45:00+09:00 Subject: Re: how to say # in ruby Gerry Ford wrote: > Well, you sound friendly enough. I'm very friendly. Just ask anybody. > My second question is about the shebang line: #! > I was surprised to find that it matters what's written here when using > the windows platform. There is no env folder in the bin folder, so if > that's a path, then it's a path to nowhere. What "should" the first > line say? I would've guessed that it didn't matter, but I tried #! garbage and was also surprised to learn Ruby terminates the program with the message "test.rb:1: Can't exec garbage (fatal)". So I looked at the source code. In the load_file() function in ruby.c, there is code that inspects the first line in the script. If it starts with "#!" then the line must also contain the word "ruby". If it doesn't, then Ruby calls execv() to run the "program" that it assumes follows the #!. When execv() fails, Ruby terminates the program. If the #! is on the 2nd line, or if the first line is #! ruby then everything is copacetic. That's why #! /usr/bin/env/ruby -w works. -- Posted via http://www.ruby-forum.com/.