On Tue, 6 Jan 2004 07:20:08 +0900
Joel VanderWerf <vjoel / PATH.Berkeley.EDU> wrote:

> Ryan Pavlik wrote:
<snip>
> > 
> >     require 'rbconfig'
> >     
> >     ruby = Config::CONFIG.fetch('bindir') + "/" +
> >            Config::CONFIG.fetch('RUBY_INSTALL_NAME')
> >     ruby = Config.expand(ruby)
> >     
> >     exec ruby, "-e", 'puts VERSION'
> 
> Almost there. It won't work if you've got 1.8.0 and 1.8.1 both
> installed (if you installed 1.8.1 later, requiring 'rbconfig'
> generates an error).

Maybe installing one over the other... that's not a good thing.  I
suggest using Encap. ;-)  But it works fine with 1.8.1 here.

> And it doesn't detect that you started ruby with an alias ('alias
> rv=ruby -v)', but it's good enough for my purposes.

That, of course, is impossible.

> What I was looking for was a way to see the original command
> line. On linux I could use the proc file system, but that's just
> linux...

Oh, well, you should have said that right off.  That's not generally
possible.  Certainly, there's no (portable) way to get the invocation
from the shell or otherwise.  Even if you could, aliases are expanded
before the shell executes the command, so you couldn't get that,
either.

<snip>

-- 
Ryan Pavlik <rpav / mephle.com>

"Oh for the love of evil, not this again." - 8BT