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 7, 2019
1 parent 2c4a2e9 commit 7cc2a56
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 7cc2a56

Please sign in to comment.