Skip to content

Commit

Permalink
[bin] Improve rbenv-install so I can't make silly mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdevalias committed May 8, 2019
1 parent ebcf5e5 commit 12c8332
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions bin/rbenv-install
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ then
exit
fi

if [ "$1" == "ruby" ] && [ ! -z "$2" ]; then
if [[ "$1" == "ruby" ]] && [[ ! -z "$2" ]]; then
RUBY_VER="$2"

echo "Note: This is just a small wrapper around 'ruby-install' to prefill the 'install-dir' params for rbenv support"
Expand All @@ -19,7 +19,7 @@ if [ "$1" == "ruby" ] && [ ! -z "$2" ]; then
RBINSTDIR="$HOME/.rbenv/versions/$RUBY_VER"
RBINSTCMD="ruby-install --install-dir \"$RBINSTDIR\" ruby $RUBY_VER"

if [ -d "$RBINSTDIR" ]; then
if [[ -d "$RBINSTDIR" ]]; then
echo "It appears that the install directory already exists:"
echo " $RBINSTDIR"
echo
Expand All @@ -45,13 +45,19 @@ if [ "$1" == "ruby" ] && [ ! -z "$2" ]; then
echo "Wasn't ok, so we're quitting. Maybe try using 'ruby-install' directly?"
exit
fi
elif [ "$1" == "versions" ] || [ "$1" == "list" ]; then
exec ruby-install
elif [[ "$1" == "versions" ]] || [[ "$1" == "list" ]]; then
# This will download the latest versions, then display them
exec ruby-install --latest
elif [[ "$1" == "update" ]] || [[ "$1" == "--update" ]] || [[ "$1" == "--latest" ]] || [[ "$1" == "-L" ]]; then
exec ruby-install --latest
else
echo "This wrapper only handles one small case.. which you didn't hit. Did you want to just use 'ruby-install' directly?"
echo "This wrapper only handles a couple of small cases.. which you didn't hit."
echo
echo "Did you want to just use 'ruby-install' directly?"
echo
echo "Usage:"
echo " $0 ruby VERSION : Install the given VERSION using 'ruby-install'"
echo " $0 versions : List available versions to install"
echo " $0 update : Update list of ruby versions"
exit
fi

0 comments on commit 12c8332

Please sign in to comment.