diff --git a/libexec/rbenv b/libexec/rbenv index 0a9d0122..aab66512 100755 --- a/libexec/rbenv +++ b/libexec/rbenv @@ -27,6 +27,9 @@ else fi export RBENV_ROOT + +export RBENV_PLUGIN_PATH="${RBENV_PLUGIN_PATH}:/etc/rbenv.d:${RBENV_ROOT}/rbenv.d" + libexec_path="$(abs_dirname "$0")" export PATH="${libexec_path}:${PATH}" diff --git a/libexec/rbenv-exec b/libexec/rbenv-exec index ac060196..892e17a9 100755 --- a/libexec/rbenv-exec +++ b/libexec/rbenv-exec @@ -16,12 +16,8 @@ fi RBENV_COMMAND_PATH="$(rbenv-which "$RBENV_COMMAND")" RBENV_BIN_PATH="${RBENV_COMMAND_PATH%/*}" -shopt -s nullglob -RBENV_EXEC_PLUGINS=(/etc/rbenv.d/exec/*.bash ${RBENV_ROOT}/rbenv.d/exec/*.bash) -shopt -u nullglob - -for script in ${RBENV_EXEC_PLUGINS[@]}; do - source $script +for script in $(rbenv-plugin-scripts exec); do + source "$script" done shift 1 diff --git a/libexec/rbenv-plugin-scripts b/libexec/rbenv-plugin-scripts new file mode 100755 index 00000000..af9648ed --- /dev/null +++ b/libexec/rbenv-plugin-scripts @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -e +[ -n "$RBENV_DEBUG" ] && set -x + +# Provide rbenv completions +if [ "$1" = "--complete" ]; then + echo exec + echo rehash + echo which + exit +fi + +RBENV_COMMAND="$1" +if [ -z "$RBENV_COMMAND" ]; then + echo "usage: rbenv plugin-scripts COMMAND" >&2 + exit 1 +fi + +shopt -s nullglob +for path in ${RBENV_PLUGIN_PATH//:/$'\n'}; do + for script in $path/"$RBENV_COMMAND"/*.bash; do + echo $script + done +done +shopt -u nullglob diff --git a/libexec/rbenv-rehash b/libexec/rbenv-rehash index 3d9a9a70..ca83c54b 100755 --- a/libexec/rbenv-rehash +++ b/libexec/rbenv-rehash @@ -67,13 +67,9 @@ create_prototype_shim shopt -s nullglob make_shims ../versions/*/bin/* -# Find and run any plugins that might want to make shims too. -RBENV_REHASH_PLUGINS=(/etc/rbenv.d/rehash/*.bash ${RBENV_ROOT}/rbenv.d/rehash/*.bash) -shopt -u nullglob - # Restore the previous working directory. cd "$CUR_PATH" -for script in ${RBENV_REHASH_PLUGINS[@]}; do - source $script +for script in $(rbenv-plugin-scripts rehash); do + source "$script" done diff --git a/libexec/rbenv-which b/libexec/rbenv-which index 4ba82678..d22a91eb 100755 --- a/libexec/rbenv-which +++ b/libexec/rbenv-which @@ -52,12 +52,8 @@ else RBENV_COMMAND_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}/bin/${RBENV_COMMAND}" fi -shopt -s nullglob -RBENV_WHICH_PLUGINS=(/etc/rbenv.d/which/*.bash ${RBENV_ROOT}/rbenv.d/which/*.bash) -shopt -u nullglob - -for script in ${RBENV_WHICH_PLUGINS[@]}; do - source $script +for script in $(rbenv-plugin-scripts which); do + source "$script" done if [ -x "$RBENV_COMMAND_PATH" ]; then