fix(scripts): typo in publish.sh buildx error ('sudosudo')

${SUDO:+...}${SUDO:-...} is not the right ternary — ${SUDO:+x} expands
to 'x' when SUDO is non-empty AND ${SUDO:-y} expands to 'y' when SUDO
is empty, but they're not exclusive substitutions of the same variable
in this context, so 'sudo' (the value of $SUDO when set) leaked into
the output as 'sudosudo'. Replaced with an explicit if/else.
This commit is contained in:
yiekheng 2026-05-03 10:44:16 +08:00
parent 98a0a433a1
commit 2871e04693

View File

@ -62,9 +62,10 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PLATFORMS="${CM_IMAGE_PLATFORMS:-linux/amd64}"
if ! "${DOCKER[@]}" buildx version >/dev/null 2>&1; then
RUNNER="$([[ -n "${SUDO}" ]] && echo "root via sudo" || echo "current user")"
cat <<EOF >&2
Docker Buildx isn't reachable as the user this script runs docker as
(${SUDO:+root via sudo}${SUDO:-current user}).
(${RUNNER}).
Likely cause: buildx is installed at the per-user path
~/.docker/cli-plugins/docker-buildx, which sudo doesn't see.