Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Testing for-loop functionality of https://github.com/sstephenson/ruby-build/issues/609
#!/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
You can’t perform that action at this time.