Skip to content

Instantly share code, notes, and snippets.

@parkr
Created August 9, 2014 03:21
Show Gist options
  • Select an option

  • Save parkr/8cffcd12bf7975eae1c8 to your computer and use it in GitHub Desktop.

Select an option

Save parkr/8cffcd12bf7975eae1c8 to your computer and use it in GitHub Desktop.

Revisions

  1. parkr created this gist Aug 9, 2014.
    17 changes: 17 additions & 0 deletions bash-has-closures?.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/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"
    5 changes: 5 additions & 0 deletions output.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    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