mirror of
https://github.com/pyenv/pyenv.git
synced 2026-08-03 19:10:34 +09:00
Merge commit from fork
This commit is contained in:
parent
e4c462dc70
commit
95df7dbc7b
@ -36,12 +36,16 @@ if [ -n "$versions" ]; then
|
||||
pyenv-version-file-write "$PYENV_VERSION_FILE" "${versions[@]}"
|
||||
else
|
||||
OLDIFS="$IFS"
|
||||
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
|
||||
# which is undesired
|
||||
set -f
|
||||
IFS=: versions=($(
|
||||
pyenv-version-file-read "$PYENV_VERSION_FILE" ||
|
||||
pyenv-version-file-read "${PYENV_ROOT}/global" ||
|
||||
pyenv-version-file-read "${PYENV_ROOT}/default" ||
|
||||
echo system
|
||||
))
|
||||
set +f
|
||||
IFS="$OLDIFS"
|
||||
for version in "${versions[@]}"; do
|
||||
echo "$version"
|
||||
|
||||
@ -59,7 +59,11 @@ elif [ -n "$versions" ]; then
|
||||
pyenv-version-file-write ${FORCE:+-f }.python-version "${versions[@]}"
|
||||
else
|
||||
if version_file="$(pyenv-version-file "$PWD")"; then
|
||||
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
|
||||
# which is undesired
|
||||
set -f
|
||||
IFS=: versions=($(pyenv-version-file-read "$version_file"))
|
||||
set +f
|
||||
for version in "${versions[@]}"; do
|
||||
echo "$version"
|
||||
done
|
||||
|
||||
@ -28,6 +28,9 @@ fi
|
||||
PYENV_PREFIX_PATHS=()
|
||||
OLDIFS="$IFS"
|
||||
{ IFS=:
|
||||
# Unquoted $VAR does glob expansion (against the current dir's contents) after IFS-splitting
|
||||
# which is undesired
|
||||
set -f
|
||||
for version in ${PYENV_VERSION}; do
|
||||
if [ "$version" = "system" ]; then
|
||||
if PYTHON_PATH="$(PYENV_VERSION="${version}" pyenv-which python --skip-advice 2>/dev/null)" || \
|
||||
@ -52,6 +55,7 @@ OLDIFS="$IFS"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
}
|
||||
IFS="$OLDIFS"
|
||||
|
||||
|
||||
@ -9,7 +9,11 @@ set -e
|
||||
|
||||
exitcode=0
|
||||
OLDIFS="$IFS"
|
||||
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
|
||||
# which is undesired
|
||||
set -f
|
||||
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name)) || exitcode=$?
|
||||
set +f
|
||||
IFS="$OLDIFS"
|
||||
|
||||
unset bare
|
||||
|
||||
@ -46,6 +46,9 @@ versions=()
|
||||
OLDIFS="$IFS"
|
||||
{ IFS=:
|
||||
any_not_installed=0
|
||||
# Unquoted $VAR does glob expansion (against the current dir's contents) after IFS-splitting
|
||||
# which is undesired
|
||||
set -f
|
||||
for version in ${PYENV_VERSION}; do
|
||||
# Remove the explicit 'python-' prefix from versions like 'python-3.12'.
|
||||
normalised_version="${version#python-}"
|
||||
@ -66,6 +69,7 @@ OLDIFS="$IFS"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
}
|
||||
IFS="$OLDIFS"
|
||||
|
||||
|
||||
@ -99,6 +99,9 @@ else
|
||||
miss_prefix=" "
|
||||
OLDIFS="$IFS"
|
||||
IFS=:
|
||||
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
|
||||
# which is undesired
|
||||
set -f
|
||||
if ((${BASH_VERSINFO[0]} > 3)); then
|
||||
for i in $(pyenv-version-name || true); do
|
||||
current_versions["$i"]="1"
|
||||
@ -106,6 +109,7 @@ else
|
||||
else
|
||||
current_versions=($(pyenv-version-name || true))
|
||||
fi
|
||||
set +f
|
||||
IFS="$OLDIFS"
|
||||
include_system="1"
|
||||
fi
|
||||
@ -161,11 +165,15 @@ versions_dir_entries=("$versions_dir"/*)
|
||||
if sort --version-sort </dev/null >/dev/null 2>&1; then
|
||||
# system sort supports version sorting
|
||||
OLDIFS="$IFS"
|
||||
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
|
||||
# which is undesired
|
||||
set -f
|
||||
IFS=$'\n'
|
||||
versions_dir_entries=($(
|
||||
printf "%s\n" "${versions_dir_entries[@]}" |
|
||||
sort --version-sort
|
||||
))
|
||||
set +f
|
||||
IFS="$OLDIFS"
|
||||
fi
|
||||
|
||||
|
||||
@ -63,7 +63,11 @@ if [ -z "$PYENV_COMMAND" ]; then
|
||||
fi
|
||||
|
||||
OLDIFS="$IFS"
|
||||
# Unquoted $VAR or VAR=() of unquoted value does glob expansion (against the current dir's contents)
|
||||
# after IFS-splitting which is undesired
|
||||
set -f
|
||||
IFS=: versions=(${PYENV_VERSION:-$(pyenv-version-name -f)})
|
||||
set +f
|
||||
IFS="$OLDIFS"
|
||||
|
||||
declare -a nonexistent_versions
|
||||
|
||||
@ -16,6 +16,14 @@ load test_helper
|
||||
assert_output "1.2.3"
|
||||
}
|
||||
|
||||
@test "version with glob characters is handled correctly" {
|
||||
touch 1.1
|
||||
mkdir -p "$PYENV_ROOT"
|
||||
echo "[1-9].?*" > "$PYENV_ROOT/version"
|
||||
run pyenv-global
|
||||
assert_success "[1-9].?*"
|
||||
}
|
||||
|
||||
@test "set PYENV_ROOT/version" {
|
||||
mkdir -p "$PYENV_ROOT/versions/1.2.3"
|
||||
run pyenv-global "1.2.3"
|
||||
|
||||
@ -19,6 +19,13 @@ _setup() {
|
||||
assert_success "1.2.3"
|
||||
}
|
||||
|
||||
@test "version with glob characters is handled correctly" {
|
||||
touch 1.1
|
||||
echo "[1-9].?*" > .python-version
|
||||
run pyenv-local
|
||||
assert_success "[1-9].?*"
|
||||
}
|
||||
|
||||
@test "discovers version file in parent directory" {
|
||||
echo "1.2.3" > .python-version
|
||||
mkdir -p "subdir" && cd "subdir"
|
||||
|
||||
@ -16,6 +16,12 @@ load test_helper
|
||||
assert_failure "pyenv: version \`1.2.3' not installed"
|
||||
}
|
||||
|
||||
@test "version with glob characters is handled correctly" {
|
||||
touch 1.1
|
||||
PYENV_VERSION="[1-9].?*" run pyenv-prefix
|
||||
assert_failure "pyenv: version \`[1-9].?*' not installed"
|
||||
}
|
||||
|
||||
@test "prefix for system" {
|
||||
mkdir -p "${PYENV_TEST_DIR}/bin"
|
||||
touch "${PYENV_TEST_DIR}/bin/python"
|
||||
|
||||
@ -22,6 +22,14 @@ _setup() {
|
||||
assert_success "system"
|
||||
}
|
||||
|
||||
@test "version with glob characters is handled correctly" {
|
||||
touch 1.1
|
||||
PYENV_VERSION="[1-9].?*" run pyenv-version-name
|
||||
assert_failure <<'!'
|
||||
pyenv: version `[1-9].?*' is not installed (set by PYENV_VERSION environment variable)
|
||||
!
|
||||
}
|
||||
|
||||
@test "PYENV_VERSION can be overridden by hook" {
|
||||
create_version "2.7.11"
|
||||
create_version "3.5.1"
|
||||
|
||||
@ -79,3 +79,12 @@ OUT
|
||||
3.3.3
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "version with glob characters is handled correctly" {
|
||||
touch 1.1
|
||||
PYENV_VERSION="[1-9].?*" run pyenv-version
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
pyenv: version \`[1-9].?*' is not installed (set by PYENV_VERSION environment variable)
|
||||
OUT
|
||||
}
|
||||
|
||||
@ -63,6 +63,18 @@ OUT
|
||||
assert_success "3.3"
|
||||
}
|
||||
|
||||
@test "version with glob characters is handled correctly" {
|
||||
stub_system_python
|
||||
create_version "[1-9].?*"
|
||||
touch 1.1
|
||||
run pyenv-versions
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
* system (set by ${PYENV_ROOT}/version)
|
||||
[1-9].?*
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "multiple versions and envs" {
|
||||
stub_system_python
|
||||
create_version "2.7.6"
|
||||
|
||||
@ -90,6 +90,17 @@ Note: See 'pyenv help global' for tips on allowing multiple
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "version with glob characters is handled correctly" {
|
||||
bats_require_minimum_version 1.5.0
|
||||
touch 1.1
|
||||
PATH="$(path_without foo)" PYENV_VERSION="[1-9].?*" run -127 pyenv-which foo
|
||||
assert_failure
|
||||
assert_output <<!
|
||||
pyenv: version \`[1-9].?*' is not installed (set by PYENV_VERSION environment variable)
|
||||
pyenv: foo: command not found
|
||||
!
|
||||
}
|
||||
|
||||
@test "no executable found" {
|
||||
bats_require_minimum_version 1.5.0
|
||||
create_alt_executable_in_version "2.7" "py.test"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user