On Thu, 28 Jun 2007, Gauland, Michael wrote:
I'm a bit confused by all of this--why isn't "hashbang" just invoking the ruby interpreter directly? I think you've lost something in simplifying the example.
I got it into my noddle that it would be gnice to remove as many sources of variation between developers boxes. Currently when I distributed the tool chain I recompile ruby on each box. So I thought, let me distributed prebuilt versions of Ruby along with the new gcc4 cross compiler. Alas, on guys with older distros neither gcc4 nor ruby would run, since the old boxen didn't have the right libc.so etc. It seems the very gnotion of static linking gcc is no longer a done thing, and static linking ruby is extra hard since it has lots and lots of modules that are dlls. So someone on gcc-help mention /lib/ld-linux.so.2 which allows you to gwrap an executable and attach the gright glibraries. (No, the LD_LIBRARY_PATH trick didn't work either) Anyhoo. As the final step in building the toolchain I wrap all executables in a shell script that invokes the real executable via ld-linux.so and points it at a stash of dlls. That all works. Except the #! to #! on ruby failed. Bah! So now I have written a very small C stub that invokes ld-linux.so instead of the shell script. That works.
Any way, I had a play, and found that by modifying "flashbang" to copy all but the first line of the first argument to a temporary file, I could get it to work the way I *think* you want. I.e., using
Hmm. Evil gnotion... Won't help the #! script being interpreted by a #! script problem though..
===/home/johnc/foo/flashbang========================================== #!/bin/sh echo flashbanger echo $0 tail +2 $1 > x shift 1 /usr/bin/ruby x "$@" ====================================================================== I get: $ ./flashbang ./hashbang "Hello World" flashbanger Hello World $
I suspect the ./hashbang "Hello world" will still fail.
Of course, this assumes the first argument to flashbang is a ruby script with the first line invoking something other than ruby. I also tried adding "ruby" at the end of the first line of "hashbang": ===/home/johnc/foo/hashbang=========================================== #!/home/johnc/foo/flashbang #ruby
Gnice one... Solves the problem of the infinite recursion.
Of course, you could build your own version of ruby (or bash), in true open-source spirit!
Hmm. One solution would be to hack the gsource for ld-linux.so That'd work very well. John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : [EMAIL PROTECTED] New Zealand
