On 17 Aug 2000, Dave Thomas wrote: > Hugh Sasse Staff Elec Eng <hgs / dmu.ac.uk> writes: > > > > Can ruby detect the -w on the #! line? > > Not just detect, but honor. Try this one: > > > t.rb: #!/usr/bin/perl > print $^O, "\n"; > > > Then execute > > ruby t.rb > > Talk about a personality change.... :-) That is nice. > > > > That seems an unusual arrangement! > > Actually, it's pretty standard. Perl does it, as does the shell. If /bin/sh doesn't do this -- Hey! it never used to, but it does on Solaris. I'm not sure about bash, and I never thought about doing it with anything other than /bin/csh. > you think about it, that's how Ruby gets run in the first place from > an executable script: something (either the shell or the OS) starts > reading the script, finds the #! line and says "oops, not for me, I'll > pass this on to Ruby". I thought this was only in /bin/csh and things that (multiply) inherited from it (tcsh and the like). Actually it is more subtle than that: chmod u+x ./t.rb brains hgs 37 %> !. ./t.rb solaris brains hgs 38 %> ruby !$ ruby ./t.rb solaris brains hgs 39 %> ksh $ ./t.rb solaris $ exit brains hgs 40 %> sh $ ./t.rb solaris $ exit brains hgs 41 %> sh t.rb t.rb: print: not found t.rb: O,: not found brains hgs 42 %> ksh t.rb $^O, brains hgs 43 %> python t.rb File "t.rb", line 2 print $^O, "\n"; ^ SyntaxError: invalid syntax brains hgs 44 %> csh t.rb Variable syntax brains hgs 45 %> from within a csh session. Interesting. > > > Regards > > > > Dave > > Hugh hgs / dmu.ac.uk