Skip to content

Instantly share code, notes, and snippets.

@ptzn
Created December 25, 2009 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptzn/263697 to your computer and use it in GitHub Desktop.
Save ptzn/263697 to your computer and use it in GitHub Desktop.
chage-ruby script
#!/bin/sh
BIN_DIR=/usr/bin
RUBY18_BIN_DIR=/usr/bin
RUBY19_BIN_DIR=/opt/ruby-1.9/bin
GEMS_HOME=/var/lib/gems
if([ -z "$1" ] || ([ "$1" != "1.8" ] && [ "$1" != "1.9" ]))
then
echo "Usage: change_ruby VERSION (1.8 or 1.9)"
exit 1
fi
remove_symlinks() {
for file in erb gem irb rake rdoc ri ruby testrb
do
rm -f $BIN_DIR/$file
done
rm -f $GEMS_HOME/bin
}
create_symlinks() {
ruby_version=$1
case "$ruby_version" in
"1.8" ) ruby_bin_dir=$RUBY18_BIN_DIR;;
"1.9" ) ruby_bin_dir=$RUBY19_BIN_DIR;;
esac
for file in erb gem irb rake rdoc ri ruby testrb
do
ln -s $ruby_bin_dir/$file$ruby_version $BIN_DIR/$file
done
ln -s $GEMS_HOME/$ruby_version/bin $GEMS_HOME/bin
}
remove_symlinks
create_symlinks $1
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment