mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Fix resolution of a name that's a prefix of another name (#2521)
This commit is contained in:
parent
904fe964b0
commit
ed1083ec27
2 changed files with 21 additions and 0 deletions
|
@ -35,6 +35,12 @@ IFS=$'\n'
|
||||||
else
|
else
|
||||||
DEFINITION_CANDIDATES=( $(python-build --definitions ) )
|
DEFINITION_CANDIDATES=( $(python-build --definitions ) )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if printf '%s\n' "${DEFINITION_CANDIDATES[@]}" | grep -qxFe "$prefix"; then
|
||||||
|
echo "$prefix"
|
||||||
|
exit $exitcode;
|
||||||
|
fi
|
||||||
|
|
||||||
# https://stackoverflow.com/questions/11856054/is-there-an-easy-way-to-pass-a-raw-string-to-grep/63483807#63483807
|
# https://stackoverflow.com/questions/11856054/is-there-an-easy-way-to-pass-a-raw-string-to-grep/63483807#63483807
|
||||||
prefix_re="$(sed 's/[^\^]/[&]/g;s/[\^]/\\&/g' <<< "$prefix")"
|
prefix_re="$(sed 's/[^\^]/[&]/g;s/[\^]/\\&/g' <<< "$prefix")"
|
||||||
# FIXME: more reliable and readable would probably be to loop over them and transform in pure Bash
|
# FIXME: more reliable and readable would probably be to loop over them and transform in pure Bash
|
||||||
|
|
|
@ -64,6 +64,21 @@ pyenv: no known versions match the prefix \`3.8'
|
||||||
!
|
!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "complete name resolves to itself" {
|
||||||
|
create_executable pyenv-versions <<!
|
||||||
|
#!$BASH
|
||||||
|
echo foo
|
||||||
|
echo foo.bar
|
||||||
|
!
|
||||||
|
|
||||||
|
run pyenv-latest foo
|
||||||
|
assert_success
|
||||||
|
assert_output <<!
|
||||||
|
foo
|
||||||
|
!
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@test "sort CPython" {
|
@test "sort CPython" {
|
||||||
create_executable pyenv-versions <<!
|
create_executable pyenv-versions <<!
|
||||||
#!$BASH
|
#!$BASH
|
||||||
|
|
Loading…
Reference in a new issue