1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-13 22:03:52 -05:00

Use version sort in pyenv versions if available (#2405)

This commit is contained in:
Pedro Fonini
2022-07-10 17:00:51 -03:00
committed by GitHub
parent 207f33fc5e
commit fdaeaf1f97
2 changed files with 62 additions and 1 deletions

View File

@@ -123,7 +123,19 @@ if [ -n "$include_system" ] && \
fi
shopt -s dotglob nullglob
for path in "$versions_dir"/*; do
versions_dir_entries=("$versions_dir"/*)
if sort --version-sort </dev/null >/dev/null 2>&1; then
# system sort supports version sorting
OLDIFS="$IFS"
IFS=$'\n'
versions_dir_entries=($(
printf "%s\n" "${versions_dir_entries[@]}" |
sort --version-sort
))
IFS="$OLDIFS"
fi
for path in "${versions_dir_entries[@]}"; do
if [ -d "$path" ]; then
if [ -n "$skip_aliases" ] && [ -L "$path" ]; then
target="$(realpath "$path")"