postmodern / chruby

Changes the current Ruby
MIT License
2.87k stars 189 forks source link

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

Open postmodern opened 11 years ago

postmodern commented 11 years ago

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 commented 11 years ago

Inspired by #212.

postmodern commented 11 years ago

Of course this will misbehave if $HOME contains spaces.

mpapis commented 11 years ago

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 - ) )
}
aprescott commented 10 years ago

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

postmodern commented 10 years ago

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