@@ -100,8 +100,19 @@ runs:
100100 current_version=$(pwsh -c '$PSVersionTable.PSVersion.ToString()' | tr -d '\r\n')
101101 echo "Current PowerShell version: $current_version"
102102
103- # Compare versions
104- if [ "$(printf '%s\n' "$clean_version" "$current_version" | sort -V | head -n1)" != "$clean_version" ]; then
103+ # Properly compare versions with version components
104+ current_major=$(echo "$current_version" | cut -d'.' -f1)
105+ current_minor=$(echo "$current_version" | cut -d'.' -f2)
106+ current_patch=$(echo "$current_version" | cut -d'.' -f3)
107+
108+ target_major=$(echo "$clean_version" | cut -d'.' -f1)
109+ target_minor=$(echo "$clean_version" | cut -d'.' -f2)
110+ target_patch=$(echo "$clean_version" | cut -d'.' -f3)
111+
112+ # Check if the current version is greater than or equal to target
113+ if [ "$current_major" -gt "$target_major" ] ||
114+ ([ "$current_major" -eq "$target_major" ] && [ "$current_minor" -gt "$target_minor" ]) ||
115+ ([ "$current_major" -eq "$target_major" ] && [ "$current_minor" -eq "$target_minor" ] && [ "$current_patch" -ge "$target_patch" ]); then
105116 echo "Current version $current_version is greater than or equal to target version $clean_version. Skipping installation."
106117 need_to_install=false
107118 else
@@ -151,8 +162,19 @@ runs:
151162 current_version=$(/usr/local/bin/pwsh -c '$PSVersionTable.PSVersion.ToString()' | tr -d '\r\n')
152163 echo "Current PowerShell version: $current_version"
153164
154- # Compare versions
155- if [ "$(printf '%s\n' "$clean_version" "$current_version" | sort -V | head -n1)" != "$clean_version" ]; then
165+ # Properly compare versions with version components
166+ current_major=$(echo "$current_version" | cut -d'.' -f1)
167+ current_minor=$(echo "$current_version" | cut -d'.' -f2)
168+ current_patch=$(echo "$current_version" | cut -d'.' -f3)
169+
170+ target_major=$(echo "$clean_version" | cut -d'.' -f1)
171+ target_minor=$(echo "$clean_version" | cut -d'.' -f2)
172+ target_patch=$(echo "$clean_version" | cut -d'.' -f3)
173+
174+ # Check if the current version is greater than or equal to target
175+ if [ "$current_major" -gt "$target_major" ] ||
176+ ([ "$current_major" -eq "$target_major" ] && [ "$current_minor" -gt "$target_minor" ]) ||
177+ ([ "$current_major" -eq "$target_major" ] && [ "$current_minor" -eq "$target_minor" ] && [ "$current_patch" -ge "$target_patch" ]); then
156178 echo "Current version $current_version is greater than or equal to target version $clean_version. Skipping installation."
157179 need_to_install=false
158180 else
0 commit comments