mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-11 13:03:46 -05:00
Extract rbenv-version-file{,-read,-write}
This commit is contained in:
@@ -1,30 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
find_version_file() {
|
||||
local root="$(pwd)"
|
||||
while [ -n "$root" ]; do
|
||||
if [ -e "${root}/.rbenv-version" ]; then
|
||||
echo "${root}/.rbenv-version"
|
||||
return 0
|
||||
fi
|
||||
root="${root%/*}"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
DEFAULT_PATH="${HOME}/.rbenv/default"
|
||||
|
||||
find_default_version_file() {
|
||||
if [ -e "$DEFAULT_PATH" ]; then
|
||||
echo "$DEFAULT_PATH"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ -z "$RBENV_VERSION" ]; then
|
||||
find_version_file || find_default_version_file || true
|
||||
else
|
||||
if [ -n "$RBENV_VERSION" ]; then
|
||||
echo "RBENV_VERSION environment variable"
|
||||
else
|
||||
rbenv-version-file
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user