pyenv-latest: sort flavors with a dotted name (e.g. pypy2.7) by version (#3613)

The sort key only split off a flavor name made of alphanumerics, so
"pypy2.7-8.0.1" kept its hyphen and the PyPy version was erroneously compared from
the second numeric field.
This commit is contained in:
vulragrag-star authored and GitHub committed 2026-10-29 21:21:16 +03:00
1 parent c34a063004
commit 973bfbcd41
2 files changed
+17 -2

No files matched your search

+2 -2
View File
@@ -85,14 +85,14 @@ IFS=$'\n'
DEFINITION_CANDIDATES=(\
$(printf '%s\n' "${DEFINITION_CANDIDATES[@]:-}" | \
awk \
'{ if (match($0,"^[[:alnum:]]+-"))
'{ if (match($0,"^[[:alnum:].]+-"))
{ print substr($0,0,RLENGTH-1) "." substr($0,RLENGTH+1) "..|" $0; }
else
{ print $0 "...|" $0; }
}'))
DEFINITION_CANDIDATES=(\
$(printf '%s\n' "${DEFINITION_CANDIDATES[@]:-}" \
| sort -t. -k1,1r -k 2,2nr -k 3,3nr -k4,4nr \
| sort -t. -k1,1r -k 2,2nr -k 3,3nr -k4,4nr -k5,5nr -k6,6nr \
| cut -f2 -d $'|' \
|| true))
DEFINITION="${DEFINITION_CANDIDATES[0]:-}"