mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-10 12:33:48 -05:00
Extract rbenv-version-file{,-read,-write}
This commit is contained in:
@@ -1,29 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# Read the first non-whitespace word from the specified file.
|
||||
read_version_file() {
|
||||
local words version
|
||||
while read -a words; do
|
||||
version="${words[0]}"
|
||||
if [ -n "$version" ]; then
|
||||
echo "$version"
|
||||
break
|
||||
fi
|
||||
done < "$1"
|
||||
}
|
||||
|
||||
DEFAULT_PATH="${HOME}/.rbenv/default"
|
||||
|
||||
if [ -z "$RBENV_VERSION" ]; then
|
||||
RBENV_VERSION_FILE="$(rbenv-version-origin)"
|
||||
|
||||
if [ -n "$RBENV_VERSION_FILE" ]; then
|
||||
RBENV_VERSION="$(read_version_file "$RBENV_VERSION_FILE")"
|
||||
else
|
||||
echo system > "$DEFAULT_PATH"
|
||||
RBENV_VERSION=system
|
||||
fi
|
||||
RBENV_VERSION_FILE="$(rbenv-version-file)"
|
||||
RBENV_VERSION="$(rbenv-version-file-read "$RBENV_VERSION_FILE" || true)"
|
||||
fi
|
||||
|
||||
if [ "$RBENV_VERSION" = "system" ]; then
|
||||
|
||||
Reference in New Issue
Block a user