mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Conforms OLD_RBENV_VERSION to RBENV_* convention
Keeping rbenv-controlled variables to RBENV_* "namespace" helps with discoverability (and tools like rbenv-env) but also consistency and a very minor degree of safety/isolation from env impact.
This commit is contained in:
parent
e60ad4a090
commit
8eb97549e1
2 changed files with 26 additions and 26 deletions
|
@ -45,11 +45,11 @@ fi
|
||||||
if [ "$version" = "--unset" ]; then
|
if [ "$version" = "--unset" ]; then
|
||||||
case "$shell" in
|
case "$shell" in
|
||||||
fish )
|
fish )
|
||||||
echo 'set -gu OLD_RBENV_VERSION "$RBENV_VERSION"'
|
echo 'set -gu RBENV_VERSION_OLD "$RBENV_VERSION"'
|
||||||
echo "set -e RBENV_VERSION"
|
echo "set -e RBENV_VERSION"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
echo 'OLD_RBENV_VERSION="$RBENV_VERSION"'
|
echo 'RBENV_VERSION_OLD="$RBENV_VERSION"'
|
||||||
echo "unset RBENV_VERSION"
|
echo "unset RBENV_VERSION"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -60,36 +60,36 @@ if [ "$version" = "-" ]; then
|
||||||
case "$shell" in
|
case "$shell" in
|
||||||
fish )
|
fish )
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
if set -q OLD_RBENV_VERSION
|
if set -q RBENV_VERSION_OLD
|
||||||
if [ -n "\$OLD_RBENV_VERSION" ]
|
if [ -n "\$RBENV_VERSION_OLD" ]
|
||||||
set OLD_RBENV_VERSION_ "\$RBENV_VERSION"
|
set RBENV_VERSION_OLD_ "\$RBENV_VERSION"
|
||||||
set -gx RBENV_VERSION "\$OLD_RBENV_VERSION"
|
set -gx RBENV_VERSION "\$RBENV_VERSION_OLD"
|
||||||
set -gu OLD_RBENV_VERSION "\$OLD_RBENV_VERSION_"
|
set -gu RBENV_VERSION_OLD "\$RBENV_VERSION_OLD_"
|
||||||
set -e OLD_RBENV_VERSION_
|
set -e RBENV_VERSION_OLD_
|
||||||
else
|
else
|
||||||
set -gu OLD_RBENV_VERSION "\$RBENV_VERSION"
|
set -gu RBENV_VERSION_OLD "\$RBENV_VERSION"
|
||||||
set -e RBENV_VERSION
|
set -e RBENV_VERSION
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
echo "rbenv: OLD_RBENV_VERSION is not set" >&2
|
echo "rbenv: RBENV_VERSION_OLD is not set" >&2
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
if [ -n "\${OLD_RBENV_VERSION+x}" ]; then
|
if [ -n "\${RBENV_VERSION_OLD+x}" ]; then
|
||||||
if [ -n "\$OLD_RBENV_VERSION" ]; then
|
if [ -n "\$RBENV_VERSION_OLD" ]; then
|
||||||
OLD_RBENV_VERSION_="\$RBENV_VERSION"
|
RBENV_VERSION_OLD_="\$RBENV_VERSION"
|
||||||
export RBENV_VERSION="\$OLD_RBENV_VERSION"
|
export RBENV_VERSION="\$RBENV_VERSION_OLD"
|
||||||
OLD_RBENV_VERSION="\$OLD_RBENV_VERSION_"
|
RBENV_VERSION_OLD="\$RBENV_VERSION_OLD_"
|
||||||
unset OLD_RBENV_VERSION_
|
unset RBENV_VERSION_OLD_
|
||||||
else
|
else
|
||||||
OLD_RBENV_VERSION="\$RBENV_VERSION"
|
RBENV_VERSION_OLD="\$RBENV_VERSION"
|
||||||
unset RBENV_VERSION
|
unset RBENV_VERSION
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "rbenv: OLD_RBENV_VERSION is not set" >&2
|
echo "rbenv: RBENV_VERSION_OLD is not set" >&2
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
EOS
|
EOS
|
||||||
|
@ -103,11 +103,11 @@ if rbenv-prefix "$version" >/dev/null; then
|
||||||
if [ "$version" != "$RBENV_VERSION" ]; then
|
if [ "$version" != "$RBENV_VERSION" ]; then
|
||||||
case "$shell" in
|
case "$shell" in
|
||||||
fish )
|
fish )
|
||||||
echo 'set -gu OLD_RBENV_VERSION "$RBENV_VERSION"'
|
echo 'set -gu RBENV_VERSION_OLD "$RBENV_VERSION"'
|
||||||
echo "set -gx RBENV_VERSION \"$version\""
|
echo "set -gx RBENV_VERSION \"$version\""
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
echo 'OLD_RBENV_VERSION="$RBENV_VERSION"'
|
echo 'RBENV_VERSION_OLD="$RBENV_VERSION"'
|
||||||
echo "export RBENV_VERSION=\"$version\""
|
echo "export RBENV_VERSION=\"$version\""
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -23,20 +23,20 @@ load test_helper
|
||||||
@test "shell revert" {
|
@test "shell revert" {
|
||||||
RBENV_SHELL=bash run rbenv-sh-shell -
|
RBENV_SHELL=bash run rbenv-sh-shell -
|
||||||
assert_success
|
assert_success
|
||||||
assert_line 0 'if [ -n "${OLD_RBENV_VERSION+x}" ]; then'
|
assert_line 0 'if [ -n "${RBENV_VERSION_OLD+x}" ]; then'
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "shell revert (fish)" {
|
@test "shell revert (fish)" {
|
||||||
RBENV_SHELL=fish run rbenv-sh-shell -
|
RBENV_SHELL=fish run rbenv-sh-shell -
|
||||||
assert_success
|
assert_success
|
||||||
assert_line 0 'if set -q OLD_RBENV_VERSION'
|
assert_line 0 'if set -q RBENV_VERSION_OLD'
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "shell unset" {
|
@test "shell unset" {
|
||||||
RBENV_SHELL=bash run rbenv-sh-shell --unset
|
RBENV_SHELL=bash run rbenv-sh-shell --unset
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<OUT
|
assert_output <<OUT
|
||||||
OLD_RBENV_VERSION="\$RBENV_VERSION"
|
RBENV_VERSION_OLD="\$RBENV_VERSION"
|
||||||
unset RBENV_VERSION
|
unset RBENV_VERSION
|
||||||
OUT
|
OUT
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ OUT
|
||||||
RBENV_SHELL=fish run rbenv-sh-shell --unset
|
RBENV_SHELL=fish run rbenv-sh-shell --unset
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<OUT
|
assert_output <<OUT
|
||||||
set -gu OLD_RBENV_VERSION "\$RBENV_VERSION"
|
set -gu RBENV_VERSION_OLD "\$RBENV_VERSION"
|
||||||
set -e RBENV_VERSION
|
set -e RBENV_VERSION
|
||||||
OUT
|
OUT
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ SH
|
||||||
RBENV_SHELL=bash run rbenv-sh-shell 1.2.3
|
RBENV_SHELL=bash run rbenv-sh-shell 1.2.3
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<OUT
|
assert_output <<OUT
|
||||||
OLD_RBENV_VERSION="\$RBENV_VERSION"
|
RBENV_VERSION_OLD="\$RBENV_VERSION"
|
||||||
export RBENV_VERSION="1.2.3"
|
export RBENV_VERSION="1.2.3"
|
||||||
OUT
|
OUT
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ OUT
|
||||||
RBENV_SHELL=fish run rbenv-sh-shell 1.2.3
|
RBENV_SHELL=fish run rbenv-sh-shell 1.2.3
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<OUT
|
assert_output <<OUT
|
||||||
set -gu OLD_RBENV_VERSION "\$RBENV_VERSION"
|
set -gu RBENV_VERSION_OLD "\$RBENV_VERSION"
|
||||||
set -gx RBENV_VERSION "1.2.3"
|
set -gx RBENV_VERSION "1.2.3"
|
||||||
OUT
|
OUT
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue