On 4/15/07, Austin Ziegler <halostatue / gmail.com> wrote: > On 4/5/07, Kirill A. Shutemov <k.shutemov / gmail.com> wrote: > > > echo -e '#!test\nputs "test passed"' | ruby > > -:1: Can't exec test (fatal) > > > > Ruby parse shebang and try to run program using shebang if it's not ruby. > > > > I think it's wrong. Shebang should be parsed by shell, not ruby. If I try > > to run a file using ruby, it should be run using ruby. Ruby is not a > > shell. > > This has been this way for a very long time; there is a good reason > for it but I can't remember what it is offhand. This special interpretation of the shebang line by Ruby is shared with Perl as well. I think this is a bit of the social programming both languages are famous for. Play nice with your users, even to redirect them to the appropriate tool if that's what it should be done. This behavior is consistent with the semantics of 'exec' which tries to read the shebang line and (if it is there) call the appropriate program to execute the possible script. This way, programs written for interpreters are just as good as binary programs in a way that is transparent to the user. You may always force ruby or perl to read the appropriate file if that's what you want. Maybe in Ruby, that would be: $ ruby -e 'require ("script")' (I know that for Perl $ perl -e 'do shift' script would do it) Of course (like Austin said) there could be an even more compelling reason for Ruby to do it like this. Regards, Adriano Ferreira.