chruby icon indicating copy to clipboard operation
chruby copied to clipboard

Allow RUBIES to contain dir globs that are expanded on each run

Open postmodern opened this issue 12 years ago • 5 comments

Allow RUBIES to contain dir glob strings ("$HOME/.rubies/*") which are expanded as chruby iterates over RUBIES. This would allow chruby to see rubies that were just installed into ~/.rubies/.

Example Code

RUBIES=("/opt/rubies/*" "$HOME/.rubies/*")

for ruby in ${RUBIES[@]}; do
    echo "Testing: $ruby"
    if [[ -d "$ruby" ]] && [[ "$ruby" == *$1* ]]; then
        echo "Found: $ruby"
        exit
    fi
done

postmodern avatar Oct 20 '13 12:10 postmodern

Inspired by #212.

postmodern avatar Oct 20 '13 12:10 postmodern

Of course this will misbehave if $HOME contains spaces.

postmodern avatar Oct 20 '13 13:10 postmodern

this should work https://gist.github.com/mpapis/7ffdd6e97533f92a5cff you could shorten the read lines code:

__chruby_get_dirs()
{
  # NEW LINE, BE CAREFUL
  typeset IFS="
"
  __dirs=( $( \cat - ) )
}

mpapis avatar Oct 21 '13 05:10 mpapis

@postmodern does @mpapis's approach avoid the keyword splitting problem you were facing?

aprescott avatar Feb 03 '14 22:02 aprescott

@aprescott sort of, but I want to keep $RUBIES an explicit list of directories until 1.0.0.

postmodern avatar Feb 04 '14 00:02 postmodern