I'm sorry for too late replying...

  In mail "Re: install.rb/setup.rb question"
    ptkwt / shell1.aracnet.com (Phil Tomson) wrote:

> Ok, I went off and did some investigation of the sourcecode and tried some 
> things out.  Here's the scoop:
> 
> 1) If you have no shebang at the top of a script in the bin directory 
> you'll get now shebang+path_to_ruby_bin added.
> 2) if you have: '#!/usr/bin/env ruby'  for the first line of the script it 
> will not be changed.
> 3) if you have: '#!ruby' it'll be expanded to: '#!/usr/bin/ruby'  (or 
> whatever the actual path to your ruby executable is.)  Actually, it uses 
> the following regex:  /\A\#!\s*\S*ruby\S*/
> so I found that if I had: #!/usr/bin/ruby  and then ran config and setup 
> with another version of Ruby that I have installed elsewhere it would get 
> changed to (in this particular case):
> #!/home/phil/ruby_1.7.3/bin/ruby 
> 
> So it seems to do what I would expect.  The reason why it didn't work 
> initially was that I had: '#!/usr/bin/env ruby' or no shebang at all 
> and install.rb doesn't change it (special cases).

That's right.
install.rb/setup.rb does not change the shebang line when #! does not
exist, because the installer must not modify non-script (binary) file.

Since /usr/bin/env trick is also useful, install.rb/setup.rb should not
modify it (The author might select it intentionaly).  But if the shebang
line is /usr/local/bin/ruby or /usr/bin/ruby, that's dangerous.  In the
case, the installer should modify it.

-- Minero Aoki