From e548877ead42cd474bc1c58bdd02fd1bdbc82828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohnic=CC=81?= Date: Thu, 13 Dec 2012 01:52:13 +0100 Subject: [PATCH] have `versions` also list "system" if it exists Closes #263 --- libexec/rbenv-versions | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libexec/rbenv-versions b/libexec/rbenv-versions index 2a762f24..a64e8537 100755 --- a/libexec/rbenv-versions +++ b/libexec/rbenv-versions @@ -12,14 +12,21 @@ else current_version="$(rbenv-version-name || true)" fi +print_version() { + if [ "$1" == "$current_version" ]; then + echo "${hit_prefix}$(rbenv-version)" + else + echo "${miss_prefix}$1" + fi +} + +# detect if there is system ruby +if RBENV_VERSION=system rbenv-which ruby >/dev/null 2>&1; then + print_version system +fi + for path in "${RBENV_ROOT}/versions/"*; do if [ -d "$path" ]; then - version="${path##*/}" - - if [ "$version" == "$current_version" ]; then - echo "${hit_prefix}$(rbenv-version)" - else - echo "${miss_prefix}${version}" - fi + print_version "${path##*/}" fi done