|
47 | 47 | fi |
48 | 48 |
|
49 | 49 | if command -v apt-get >/dev/null; then |
50 | | - echo "Using APT package manager (Debian/Ubuntu)…" |
| 50 | + echo "Using APT package manager (Debian/Ubuntu)..." |
51 | 51 |
|
52 | 52 | if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then |
53 | 53 | wget -qO- https://packages.microsoft.com/keys/microsoft.asc \ |
@@ -83,17 +83,21 @@ runs: |
83 | 83 | run: | |
84 | 84 | set -e |
85 | 85 |
|
86 | | - # Resolve "" / null / latest → concrete latest version (Bash‑3 safe) |
87 | | - case "${REQUESTED_VERSION:-}" in |
88 | | - ""|[Ll][Aa][Tt][Ee][Ss][Tt]|[Nn][Uu][Ll][Ll]|~) |
89 | | - REQUESTED_VERSION=$( |
90 | | - curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | |
91 | | - grep '"tag_name"' | head -n1 | |
92 | | - sed -E 's/.*"v?([^"]+)".*/\1/' |
93 | | - ) |
94 | | - echo "Latest stable PowerShell release detected: $REQUESTED_VERSION" |
95 | | - ;; |
96 | | - esac |
| 86 | + # Resolve "" / null / latest → concrete latest version |
| 87 | + if [[ -z "${REQUESTED_VERSION}" || "${REQUESTED_VERSION}" =~ ^[Ll][Aa][Tt][Ee][Ss][Tt]$ || "${REQUESTED_VERSION}" =~ ^[Nn][Uu][Ll][Ll]$ || "${REQUESTED_VERSION}" == "~" ]]; then |
| 88 | + REQUESTED_VERSION=$( |
| 89 | + curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | |
| 90 | + grep '"tag_name"' | head -n1 | |
| 91 | + sed -E 's/.*"v?([^"]+)".*/\1/' |
| 92 | + ) |
| 93 | + echo "Latest stable PowerShell release detected: $REQUESTED_VERSION" |
| 94 | + fi |
| 95 | +
|
| 96 | + # Validate REQUESTED_VERSION is not empty |
| 97 | + if [[ -z "${REQUESTED_VERSION}" ]]; then |
| 98 | + echo "Error: Could not determine a valid PowerShell version." |
| 99 | + exit 1 |
| 100 | + fi |
97 | 101 |
|
98 | 102 | DETECTED_VERSION=$(pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()' 2>/dev/null || true) |
99 | 103 | if [[ "$DETECTED_VERSION" == "$REQUESTED_VERSION" ]]; then |
|
0 commit comments