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. I used this analogy in the discussion I had: $ openoffice finances.doc shouldn't run finances.doc because it has a shebang line, it should try to read it. So reading for an "editing" tool and interpreting for an interpreter is the same thing in my opinion. I noticed all this when I was doing ruby -c randomfile.pl to make some vim(:make) stuff. Random file completion. :-) ... In the end, who is right? Perl/Ruby or Python. BR,
on 2006-05-14 14:21
on 2006-05-14 15:22
On Sun, 2006-05-14 at 21:19 +0900, Benjamin Andresen wrote: > > > [...] > 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).
on 2006-05-14 18:17
Ross Bamford wrote: > 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). So does the shebang always over-ride settings that you have call to the script like this, $ ruby -W0 code.rb where code.rb has, #!/usr/bin/ruby -w ... Seems to for me.