mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-14 20:39:55 -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
|
||||
DEFINITION_CANDIDATES=( $(python-build --definitions ) )
|
||||
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
|
||||
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
|
||||
|
|
|
@ -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" {
|
||||
create_executable pyenv-versions <<!
|
||||
#!$BASH
|
||||
|
|
Loading…
Reference in a new issue