From 516f9fc51b84b4ac0fc7d67e1ac21e631fb785e8 Mon Sep 17 00:00:00 2001 From: Dmitrii Creed Date: Wed, 24 Jun 2026 18:30:08 +0400 Subject: [PATCH] fix: embed release version into sc.sh at build time + guard compareNumber empty args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit push.yaml line 637 used single-quoted sed, so `${VERSION}` was written literally into sc.sh instead of being expanded to the actual release tag. Result: every downloaded sc.sh had `VERSION="${VERSION}"` → empty at runtime → `semver_compare "" "$CURRENT"` → `$((2026 - ))` syntax error for any user who already had sc installed (sc upgrade / curl | bash). Root-cause fix (push.yaml): switch to double-quoted sed so the CI env var expands before the sed script is built. Belt-and-suspenders fix (sc.sh): - compareNumber: guard one-empty-arg cases (previously only both-empty) - version-compare block: skip semver_compare when VERSION is empty rather than crashing; empty VERSION = no specific target = always fetch latest Signed-off-by: Dmitrii Creed --- .github/workflows/push.yaml | 2 +- sc.sh | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index a7989ccf..2bae333a 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -638,7 +638,7 @@ jobs: VERSION: ${{ needs.prepare.outputs.version }} run: | cp sc.sh .sc/stacks/dist/bundle/sc.sh - sed -i -e 's/VERSION="0\.0\.0"/VERSION="${VERSION}"/g' .sc/stacks/dist/bundle/sc.sh + sed -i -e "s/VERSION=\"0\\.0\\.0\"/VERSION=\"${VERSION}\"/" .sc/stacks/dist/bundle/sc.sh echo "${VERSION}" > .sc/stacks/dist/bundle/version # Sign the post-template sc.sh that will land on dist.simple-container.com. # Signing the *post-sed* artifact is intentional: consumers verify the diff --git a/sc.sh b/sc.sh index 17aff144..9686cad0 100755 --- a/sc.sh +++ b/sc.sh @@ -62,6 +62,16 @@ compareNumber() { printf "%s" "0" return fi + # Guard: empty first arg means second is "greater" (newer) + if [ -z "$1" ]; then + printf "%s" "-1" + return + fi + # Guard: empty second arg means first is "greater" + if [ -z "$2" ]; then + printf "%s" "1" + return + fi [ $(($2 - $1)) -gt 0 ] && printf "%s" "-1" [ $(($2 - $1)) -lt 0 ] && printf "1" @@ -708,7 +718,7 @@ FORCE_UPDATE="true" fi VERSION_COMPARE="1" -if [[ "$CURRENT" != "null" ]]; then +if [[ "$CURRENT" != "null" && -n "$VERSION" ]]; then VERSION_COMPARE="$(semver_compare "$VERSION" "$CURRENT" || echo "1")" fi