From 5be66da9f4053137a320058495031d0af6db29b4 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Thu, 18 Aug 2011 14:32:33 -0500 Subject: [PATCH] Rename rbenv-default to rbenv-global --- README.md | 20 ++++++++++---------- completions/rbenv.bash | 2 +- completions/rbenv.zsh | 2 +- libexec/rbenv-default | 11 ----------- libexec/rbenv-global | 13 +++++++++++++ libexec/rbenv-help | 14 +++++++------- libexec/rbenv-set-default | 4 ++-- libexec/rbenv-version-file | 13 ++++++++++--- libexec/rbenv-version-name | 2 -- 9 files changed, 44 insertions(+), 37 deletions(-) delete mode 100755 libexec/rbenv-default create mode 100755 libexec/rbenv-global diff --git a/README.md b/README.md index c2af643..10942cf 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ tools that do one thing well. ### rbenv _does…_ -* Let you **change the default Ruby version** on a per-user basis. +* Let you **change the global Ruby version** on a per-user basis. * Provide support for **per-project Ruby versions**. * Allow you to **override the Ruby version** with an environment variable. @@ -42,7 +42,7 @@ tools that do one thing well. * [1 How It Works](#section_1) * [2 Installation](#section_2) * [3 Usage](#section_3) - * [3.1 default](#section_3.1) + * [3.1 global](#section_3.1) * [3.2 local](#section_3.2) * [3.3 versions](#section_3.3) * [3.4 version](#section_3.4) @@ -122,26 +122,26 @@ when installing a gem that provides a binary). Like `git`, the `rbenv` command delegates to subcommands based on its first argument. The most common subcommands are: -### 3.1 default +### 3.1 global -Sets the default version of Ruby to be used in all shells by writing -the version name to the `~/.rbenv/default` file. This version can be +Sets the global version of Ruby to be used in all shells by writing +the version name to the `~/.rbenv/global` file. This version can be overridden by a per-project `.rbenv-version` file, or by setting the `RBENV_VERSION` environment variable. - $ rbenv default 1.9.2-p290 + $ rbenv global 1.9.2-p290 The special version name `system` tells rbenv to use the system Ruby (detected by searching your `$PATH`). -When run without a version number, `rbenv default` reports the -currently configured default version. +When run without a version number, `rbenv global` reports the +currently configured global version. ### 3.2 local Sets a local per-project Ruby version by writing the version name to an `.rbenv-version` file in the current directory. This version -overrides the default, and can be overridden itself by setting the +overrides the global, and can be overridden itself by setting the `RBENV_VERSION` environment variable. $ rbenv local rbx-1.2.4 @@ -157,7 +157,7 @@ the currently active version. $ rbenv versions 1.8.7-p352 1.9.2-p290 - * 1.9.3-preview1 (set by /Users/sam/.rbenv/default) + * 1.9.3-preview1 (set by /Users/sam/.rbenv/global) jruby-1.6.3 rbx-1.2.4 ree-1.8.7-2011.03 diff --git a/completions/rbenv.bash b/completions/rbenv.bash index 493a6a7..8d3bbd7 100644 --- a/completions/rbenv.bash +++ b/completions/rbenv.bash @@ -17,7 +17,7 @@ _rbenv() { local prev="${COMP_WORDS[COMP_CWORD-1]}" case "$prev" in - set-* | default | local | prefix ) + set-* | global | local | prefix ) _rbenv_versions ;; * ) diff --git a/completions/rbenv.zsh b/completions/rbenv.zsh index efaebe4..105239c 100644 --- a/completions/rbenv.zsh +++ b/completions/rbenv.zsh @@ -14,7 +14,7 @@ _rbenv_versions() { _rbenv() { case "$words[2]" in - set-* | default | local | prefix ) _rbenv_versions ;; + set-* | global | local | prefix ) _rbenv_versions ;; * ) _rbenv_commands ;; esac } diff --git a/libexec/rbenv-default b/libexec/rbenv-default deleted file mode 100755 index d176e0c..0000000 --- a/libexec/rbenv-default +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -e - -RBENV_VERSION="$1" -RBENV_VERSION_FILE="${HOME}/.rbenv/default" - -if [ -n "$RBENV_VERSION" ]; then - rbenv-version-file-write "$RBENV_VERSION_FILE" "$RBENV_VERSION" -else - rbenv-version-file-read "$RBENV_VERSION_FILE" || echo system -fi diff --git a/libexec/rbenv-global b/libexec/rbenv-global new file mode 100755 index 0000000..42cedda --- /dev/null +++ b/libexec/rbenv-global @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -e + +RBENV_VERSION="$1" +RBENV_VERSION_FILE="${HOME}/.rbenv/global" + +if [ -n "$RBENV_VERSION" ]; then + rbenv-version-file-write "$RBENV_VERSION_FILE" "$RBENV_VERSION" +else + rbenv-version-file-read "$RBENV_VERSION_FILE" || + rbenv-version-file-read "${HOME}/.rbenv/default" || + echo system +fi diff --git a/libexec/rbenv-help b/libexec/rbenv-help index 4acb7dc..36fcf26 100755 --- a/libexec/rbenv-help +++ b/libexec/rbenv-help @@ -22,7 +22,7 @@ case "$1" in Some useful rbenv commands are: commands List all commands rehash Rehash rbenv shims (run this after installing binaries) - default Set or show the default Ruby version + global Set or show the global Ruby version local Set or show the local directory-specific Ruby version version Show the current Ruby version versions List all Ruby versions known by rbenv @@ -30,11 +30,11 @@ Some useful rbenv commands are: See 'rbenv help ' for more information on a specific command. For more information, see: https://github.com/sstephenson/rbenv#readme" ;; -default) echo "usage: rbenv default +global) echo "usage: rbenv global -Sets the default Ruby version. You can override the default at any time -by setting a directory-specific version with \`rbenv local' or by -setting the RBENV_VERSION environment variable. +Sets the global Ruby version. You can override the global version at +any time by setting a directory-specific version with \`rbenv local' +or by setting the RBENV_VERSION environment variable. $(print_set_version)" ;; @@ -45,8 +45,8 @@ name to a file named '.rbenv-version'. When you run a Ruby command, rbenv will look for an '.rbenv-version' file in the current directory and each parent directory. If no such -file is found in the tree, rbenv will use the default Ruby version -specified with \`rbenv default', or the version specified in the +file is found in the tree, rbenv will use the global Ruby version +specified with \`rbenv global', or the version specified in the RBENV_VERSION environment variable. $(print_set_version)" diff --git a/libexec/rbenv-set-default b/libexec/rbenv-set-default index cf68d57..a1fec3d 100755 --- a/libexec/rbenv-set-default +++ b/libexec/rbenv-set-default @@ -1,9 +1,9 @@ #!/usr/bin/env bash set -e -{ echo "rbenv: warning: \`set-default' has been renamed to \`default'" +{ echo "rbenv: warning: \`set-default' has been renamed to \`global'" echo " and will be removed in v0.3.0" echo } >&2 -exec rbenv-default "$@" +exec rbenv-global "$@" diff --git a/libexec/rbenv-version-file b/libexec/rbenv-version-file index bb4da5b..a0c8720 100755 --- a/libexec/rbenv-version-file +++ b/libexec/rbenv-version-file @@ -1,8 +1,6 @@ #!/usr/bin/env bash set -e -DEFAULT_PATH="${HOME}/.rbenv/default" - root="$(pwd)" while [ -n "$root" ]; do if [ -e "${root}/.rbenv-version" ]; then @@ -12,4 +10,13 @@ while [ -n "$root" ]; do root="${root%/*}" done -echo "$DEFAULT_PATH" +GLOBAL_PATH="${HOME}/.rbenv/global" +DEFAULT_PATH="${HOME}/.rbenv/default" + +if [ -e "$GLOBAL_PATH" ]; then + echo "$GLOBAL_PATH" +elif [ -e "$DEFAULT_PATH" ]; then + echo "$DEFAULT_PATH" +else + echo "$GLOBAL_PATH" +fi diff --git a/libexec/rbenv-version-name b/libexec/rbenv-version-name index a9c0d1a..4782de7 100755 --- a/libexec/rbenv-version-name +++ b/libexec/rbenv-version-name @@ -1,8 +1,6 @@ #!/usr/bin/env bash set -e -DEFAULT_PATH="${HOME}/.rbenv/default" - if [ -z "$RBENV_VERSION" ]; then RBENV_VERSION_FILE="$(rbenv-version-file)" RBENV_VERSION="$(rbenv-version-file-read "$RBENV_VERSION_FILE" || true)"