Commit b275e87c by Mislav Marohnić

Merge pull request #632 from sstephenson/definitions-completion

`rbenv install` completion includes definitions from plugins
parents aaf50ec6 56c8f296
...@@ -24,15 +24,24 @@ ...@@ -24,15 +24,24 @@
set -e set -e
[ -n "$RBENV_DEBUG" ] && set -x [ -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 # Provide rbenv completions
if [ "$1" = "--complete" ]; then if [ "$1" = "--complete" ]; then
exec ruby-build --definitions exec ruby-build --definitions
fi fi
if [ -z "$RBENV_ROOT" ]; then
RBENV_ROOT="${HOME}/.rbenv"
fi
# Load shared library functions # Load shared library functions
eval "$(ruby-build --lib)" eval "$(ruby-build --lib)"
...@@ -51,15 +60,6 @@ indent() { ...@@ -51,15 +60,6 @@ indent() {
sed 's/^/ /' 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 FORCE
unset SKIP_EXISTING unset SKIP_EXISTING
unset KEEP unset KEEP
......
...@@ -110,3 +110,17 @@ Available versions: ...@@ -110,3 +110,17 @@ Available versions:
${RBENV_ROOT}/plugins/foo/share/ruby-build ${RBENV_ROOT}/plugins/foo/share/ruby-build
OUT 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 <<OUT
${RBENV_ROOT}/plugins/bar/share/ruby-build
${RBENV_ROOT}/plugins/foo/share/ruby-build
OUT
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment