From 132e591503a48172a0f52eb9e1caae541cc0b689 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Wed, 21 Oct 2026 07:07:05 -0700 Subject: [PATCH] fix(lsphp-apt-upgrade): no early-exit readers under pipefail apt-cache madison | grep -q and apt-cache policy | awk '...exit' can SIGPIPE the writer under pipefail and report lsphp missing when it is there. Read each output into a variable and match in the shell. Fixes the Shell-Checks failure on trunk (lsphp-info-probe.test.sh structural scan). Tested: lsphp-info-probe.test.sh 36/36, shellcheck clean, and the script run in litespeedtech/openlitespeed:1.8.4-lsphp85 upgrades 8.5.0 -> 8.5.11 OK. Co-Authored-By: Claude Opus 5.5 --- scripts/lsphp-apt-upgrade.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/lsphp-apt-upgrade.sh b/scripts/lsphp-apt-upgrade.sh index 377cd73..6f59090 100755 --- a/scripts/lsphp-apt-upgrade.sh +++ b/scripts/lsphp-apt-upgrade.sh @@ -49,11 +49,16 @@ echo "lsphp-apt-upgrade: base image lsphp${PHPVER}=$(dpkg-query -W -f='${Version # The candidate for lsphpNN must come from the LiteSpeed repo — not "none", and # not merely whatever is already installed. -if ! apt-cache madison "lsphp${PHPVER}" | grep -q 'rpms.litespeedtech.com'; then +# Read each output into a variable and match in the shell: piping into an +# early-exit reader (grep -q, awk ... exit) under pipefail can SIGPIPE the writer +# and report "missing" for a package that is there (scripts/tests/lsphp-info-probe.test.sh). +MADISON=$(apt-cache madison "lsphp${PHPVER}") +if [[ "$MADISON" != *rpms.litespeedtech.com* ]]; then apt-cache policy "lsphp${PHPVER}" >&2 || true die "the LiteSpeed apt repo does not offer lsphp${PHPVER} (repo missing from sources, or its index is empty)." fi -CAND=$(apt-cache policy "lsphp${PHPVER}" | awk '/Candidate:/ {print $2; exit}') +POLICY=$(apt-cache policy "lsphp${PHPVER}") +CAND=$(awk '/Candidate:/ {print $2; exit}' <<<"$POLICY") echo "lsphp-apt-upgrade: repo candidate lsphp${PHPVER}=${CAND}" if [ "$OS_UPGRADE" = 1 ]; then