From: Paul Brannan Date: 2001-12-05T05:36:01+09:00 Subject: [ruby-talk:27480] Re: Shebangikowksy On Wed, Dec 05, 2001 at 04:09:26AM +0900, Martin Weber wrote: > If I write software I want people to be able to use it easily, all they > should need to know is what the script (which sometimes turns out to be > a big bad huge program, not a "dirty little script") will do, not which > interpreter is used or where to find this one. I've had enough "bug-reports" > from a couple of people who work in a department as chip-designers, using > unix as their platform as of the availability of certain software for it, > that the program I've wrote for them wouldn't work, because dumb me hard- > coded the path in the first place. Personally, if I write software, I want to have fun writing it. If I want to make sure that software I write works on as many systems as possible, then I'm going to have to do things that may not be fun. For example, the /usr/bin/env solution doesn't work in the case that /usr is not mounted or /usr is simply not present (a condition that I have run into before). So to make sure that the script works in this condition: #!/bin/sh case "$PATH" in "") PATH=$PATH:/usr/bin:/usr/local/bin ;; esac ruby -w -e"eval((['']*5+File.readlines(\"$0\")[5..-1]).join(\"\n\"),nil,\"$0\")" exit $? --- Ruby script follows --- puts "foo!" This also solves the -w problem (/usr/bin/env won't let you pass any arguments to the program it calls, because it receives everything in ARGV[1]). Another solution is to use: #!/bin/nice ruby which solves the missing /usr problem but not the -w problem (and runs the script with a modified priority). > In the end I have to admit, though, that there is no 'perfect' way. Sigh :( Yep. I think this is a problem that can't be solved without changing Unix. Apart from that, every solution we come up with is going to be a tradeoff of some form or another. Personally, I'll leave my scripts -x and tell the user to use ruby -S. Paul