Skip to content

Instantly share code, notes, and snippets.

@parkr
Created August 9, 2014 03:21
Show Gist options
  • Save parkr/8cffcd12bf7975eae1c8 to your computer and use it in GitHub Desktop.
Save parkr/8cffcd12bf7975eae1c8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
DEFINITION_PATH="2.1.1-github"
RUBY_BUILD_DEFINITIONS="$HOME/code/rbenv-custom-definitions/support"
RUBY_BUILD_DEFINITIONS="/usr/local/share/ruby-build:${RUBY_BUILD_DEFINITIONS}"
echo "$RUBY_BUILD_DEFINITIONS" | tr ":" "\n" | sed '/^$/d' | while read DEFINITION_DIRECTORY; do
echo "Testing ${DEFINITION_DIRECTORY}/${DEFINITION_PATH}"
if [ -e "${DEFINITION_DIRECTORY}/${DEFINITION_PATH}" ]; then
echo "It worked!"
DEFINITION_PATH="${DEFINITION_DIRECTORY}/${DEFINITION_PATH}"
echo "New definition path: $DEFINITION_PATH"
break
fi
done
echo "Resulting definition path: $DEFINITION_PATH"
Testing /usr/local/share/ruby-build/2.1.1-github
Testing /Users/parker/code/rbenv-custom-definitions/support/2.1.1-github
It worked!
New definition path: /Users/parker/code/rbenv-custom-definitions/support/2.1.1-github
Resulting definition path: 2.1.1-github
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment