Well to start with, you wouldn't need to write a C application - a simple bash ditty would do you fine.
I think the cleanest possible solution would involve the update-alternatives
system. This is how, for example, Ubuntu manages to keep various Java virtual machines separated while installed alongside each other. The problem is you need to set it up yourself.
I just came across a mailing-list post that does seem to do most of the heavy lifting for you. You might need to change the version numbers slightly but other than that, you should get the idea.
For posterity (in case Google nixes the URL or the thread), I'll copy in the business end now but I take no credit for writing it.
If any of you are using Ubuntu this is a pretty nice way to manage multiple
ruby interpreters.
It has the advantage of managing the manpages, ri, and irb as "slaves", so
they change when a new interpreter is selected.
here's the code:
# become root
su
# make sure the packages are installed for 1.8 & 1.9
aptitude install -s ~n^ruby1.[89]$ ~n^irb1.[89]$ ~n^ri1.[89]
# install ruby1.8 & friends with priority 500
# so this will be the default "auto" choice
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.8 500 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
/usr/share/man/man1/ruby.1.8.gz \
--slave /usr/bin/ri ri /usr/bin/ri1.8 \
--slave /usr/bin/irb irb /usr/bin/irb1.8
# install ruby1.9 & friends with priority 400
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9 400 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
/usr/share/man/man1/ruby.1.9.gz \
--slave /usr/bin/ri ri /usr/bin/ri1.9 \
--slave /usr/bin/irb irb /usr/bin/irb1.9
# choose your interpreter
# changes symlinks for /usr/bin/ruby ,
# /usr/bin/irb, /usr/bin/ri and man (1) ruby
update-alternatives --config ruby
for those with additional interpreters in say /usr/local/bin, other Debian
variants, or managing other tools, vary as required.
% man update-alternatives
hope wrapping didn't mangle it too much, and that someone finds this useful
...
--
cheers,
David Lee