mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/Mapleawaa/PVE-Tools-9.git
synced 2026-09-20 08:03:35 +08:00
fix: strip pre-release suffix in version comparison
sort -V treats "-beta" suffix as lexicographically greater than plain version, causing 10.0.0-beta to appear newer than 10.0.0. Strip -beta/-alpha/-rc before comparing to fix this.
This commit is contained in:
@@ -269,7 +269,11 @@ pve_tools_version_gt() {
|
||||
local current="$2"
|
||||
|
||||
[[ -n "$newer" && -n "$current" ]] || return 1
|
||||
[[ "$(printf '%s\n' "$newer" "$current" | sort -V | tail -n1)" == "$newer" && "$newer" != "$current" ]]
|
||||
# Strip pre-release suffixes (-beta, -alpha, -rc) so sort -V compares only
|
||||
# the numeric version; a pre-release is never newer than its base release.
|
||||
local newer_clean="${newer%%-*}"
|
||||
local current_clean="${current%%-*}"
|
||||
[[ "$(printf '%s\n' "$newer_clean" "$current_clean" | sort -V | tail -n1)" == "$newer_clean" && "$newer_clean" != "$current_clean" ]]
|
||||
}
|
||||
# 写入配置块(带标记)
|
||||
# 用法: apply_block <file> <marker> <content>
|
||||
|
||||
Reference in New Issue
Block a user