From 56c8f296ce781b747ae95e6c357c1a0b729f064d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 8 Sep 2014 20:14:33 -0700 Subject: [PATCH] `rbenv install` completion includes definitions from plugins Before, `ruby-build --definitions` was invoked sooner than RUBY_BUILD_DEFINITIONS was built up with paths from rbenv plugins. --- bin/rbenv-install | 26 +++++++++++++------------- test/rbenv.bats | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/bin/rbenv-install b/bin/rbenv-install index 640f7553..8267f68f 100755 --- a/bin/rbenv-install +++ b/bin/rbenv-install @@ -24,15 +24,24 @@ set -e [ -n "$RBENV_DEBUG" ] && set -x +if [ -z "$RBENV_ROOT" ]; then + RBENV_ROOT="${HOME}/.rbenv" +fi + +# Add `share/ruby-build/` directory from each rbenv plugin to the list of +# paths where build definitions are looked up. +shopt -s nullglob +for plugin_path in "$RBENV_ROOT"/plugins/*/share/ruby-build; do + RUBY_BUILD_DEFINITIONS="${RUBY_BUILD_DEFINITIONS}:${plugin_path}" +done +export RUBY_BUILD_DEFINITIONS +shopt -u nullglob + # Provide rbenv completions if [ "$1" = "--complete" ]; then exec ruby-build --definitions fi -if [ -z "$RBENV_ROOT" ]; then - RBENV_ROOT="${HOME}/.rbenv" -fi - # Load shared library functions eval "$(ruby-build --lib)" @@ -51,15 +60,6 @@ indent() { sed 's/^/ /' } -# Add `share/ruby-build/` directory from each rbenv plugin to the list of -# paths where build definitions are looked up. -shopt -s nullglob -for plugin_path in "$RBENV_ROOT"/plugins/*/share/ruby-build; do - RUBY_BUILD_DEFINITIONS="${RUBY_BUILD_DEFINITIONS}:${plugin_path}" -done -export RUBY_BUILD_DEFINITIONS -shopt -u nullglob - unset FORCE unset SKIP_EXISTING unset KEEP diff --git a/test/rbenv.bats b/test/rbenv.bats index 72751cb5..ff0bebb1 100644 --- a/test/rbenv.bats +++ b/test/rbenv.bats @@ -110,3 +110,17 @@ Available versions: ${RBENV_ROOT}/plugins/foo/share/ruby-build OUT } + +@test "completion results include build definitions from plugins" { + mkdir -p "${RBENV_ROOT}/plugins/foo/share/ruby-build" + mkdir -p "${RBENV_ROOT}/plugins/bar/share/ruby-build" + stub ruby-build "--definitions : echo \$RUBY_BUILD_DEFINITIONS | tr ':' $'\\n'" + + run rbenv-install --complete + assert_success + assert_output <