From: Ross Bamford Date: 2006-05-14T22:20:37+09:00 Subject: Re: shebang woes / syntax check weirdness? On Sun, 2006-05-14 at 21:19 +0900, Benjamin Andresen wrote: > Hello everyone, I just noticed that even though I call ruby form the > command line with a file as an argument it will execute the shebang > line. > Is this intentional behaviour? Because for me it doesn't hold to the > POLS. > > I had a discussion with somebody about what should happen when you run > ruby with a file as an argument. We disagreed, so I didn't want to file > a bug right away, but hear some comments on the issue before. (I don't > know where to file bugs either. ;-) > > From my perspective it should work the following way: > > $ ruby myrubyfile.rb > It will run ruby and it ignores the shebang line (it starts with a #, so > it's clearly an comment.) > > This doesn't work though, so if my shebang line is the following: > "#!/usr/bin/perl", it will run perl. > The same if you use "#!/bin/rm /etc/fstab" as your shebang line. > If would basically run the shebang line. > > Obviously if you run your script the following way: ./myrubyfile.rb > this is fine and intended. Because it has to check the shebang line > to see how it has to be interpreted / executed. > > Python on the other hand does it right... If I run: > $ python myrubyfile.rb > it will ignore the shebang line and try to interpret it. > > perl shows the same behaviour as ruby... This also got me thinking if I > may be completely off. > [...] > In the end, who is right? Perl/Ruby or Python. IMHO, Ruby and Perl have it right - recognising the shebang line means any options there will be used - often you want options like -W or -K to stay with the script in my experience (not to mention stuff like little one-liner scripts using -n and so on). -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk