[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Guess what this will do...

John Carter

6/26/2007 11:28:00 PM

1 Answer

Anthony Martinez

6/27/2007 5:54:00 PM

0

On Wed, Jun 27, 2007 at 08:28:07AM +0900, John Carter wrote:
> Without cheating (trying to run it) what will this pair of files do under Linux....
>

[lots of stuff snipped]

> WHAT THE HELL!? Why?
>
> Well, deep within ruby/ruby.c is a chunk of code that looks for a #!
> on the first line. If it contains the word "ruby" anywhere, it ignores
> it. If it doesn't it says, Oh dear. This one wasn't actually for me. I
> better be gnice and exec that interpreter and feed it this script...
>

That's a Perlism. man perlrun says:
If the #! line does not contain the word "perl", the program named
after the #! is executed instead of the Perl interpreter. This is
slightly bizarre, but it helps people on machines that don't do #!,
because they can tell a program that their SHELL is /usr/bin/perl,
and Perl will then dispatch the program to the correct interpreter
for them.

I'm a bit surprised that ruby mimicks this behavior! Does it even
_build_ on systems that don't do ``#!''?


> All in all, you can tell I have a had rather exotic and frustrating
> day or three.
>
> John Carter Phone : (64)(3) 358 6639
> Tait Electronics Fax : (64)(3) 359 4632
> PO Box 1645 Christchurch Email : john.carter@tait.co.nz
> New Zealand
>
>

--
I saw `cout' being shifted "Hello world" times to the left and stopped right
there.
-- Steve Gonedes