In message <apfia9$aq1$05$1 / news.t-online.com>
szegedy / t-online.de writes:

> I also wanted to write a more intelligent cd
> (change sirectory) script in Ruby. Of course there is
> an obvious problem I can't solve: the bash opens
> a new shell for the script, so the working directory
> remains unchanged in the shell.

How about ruby script only make a path to cd and do actual cd by shell
function or alias?  Namely:

    ~> function mcd () {cd `ruby /tmp/foo.rb`}
    ~> cat > /tmp/foo.rb
    puts "/tmp"
    ^D
    ~> mcd
    /tmp>

Of course a script may do more useful thing, and a function/alias must
be more safe; at least a function/alias should check exit status of
the script and the script signals failure on such as no directory to
cd being found.


> . /usr/bin/ruby
> 
> I thought, it would run ruby in the current environment

No, probably ksh also doesn't.  `.' in sh-derived shells means `run
the *script* in the current context.  So `. /usr/bin/ruby' evaluates
ruby itself as shell script.


-- 
kjana / dm4lab.to                               October 27, 2002
Behind the clouds is the sun still shining.