Merge pull request #36 from kristianwind/case-not-grep-q
CI / Static checks (push) Successful in 48s
CI / WordPress latest + WooCommerce latest on PHP 8.3 (push) Successful in 1m0s

Replace the two growing `| grep -q` checks with `case`
This commit is contained in:
Kristian Wind
2026-09-20 10:30:10 +02:00
committed by GitHub
2 changed files with 25 additions and 5 deletions
+16 -3
View File
@@ -200,12 +200,25 @@ if [ -z "$feed" ]; then
exit 1 exit 1
fi fi
printf '%s' "$feed" | grep -q '"browser_download_url"' || { # `case`, not `printf … | grep -q`. Under `set -o pipefail` a grep that
# MATCHES can make the pipeline exit 141: grep closes the pipe on the first
# hit and the producer takes SIGPIPE, which pipefail reports as failure. So a
# match becomes an error, in the publishing path, with a message saying the
# feed has no download URL when it plainly does.
#
# Not reachable today — the feed is 3.5 KB and the pipe buffer is 64 KB — but
# it grows about 1.9 KB per release, so it arrives around release 34. A bug on
# a timer is worse than a bug, because nothing about the commit that trips it
# will have anything to do with it. `case` has no pipe, no fork and no
# producer to signal.
case "$feed" in
*'"browser_download_url"'*) ;;
*)
echo echo
ci_fail "The release is readable, but it has no zip attached. WordPress would be offered an update it cannot download." ci_fail "The release is readable, but it has no zip attached. WordPress would be offered an update it cannot download."
exit 1 exit 1
} ;;
esac
# Checked at the address the PLUGIN builds, not the one the API reports. # Checked at the address the PLUGIN builds, not the one the API reports.
# #
# A forge fills browser_download_url from its own configured root URL, which is # A forge fills browser_download_url from its own configured root URL, which is
+9 -2
View File
@@ -122,8 +122,15 @@ for path in $referenced; do
case "$path" in */*) ;; *) continue ;; esac case "$path" in */*) ;; *) continue ;; esac
[ -d "${path%%/*}" ] || continue [ -d "${path%%/*}" ] || continue
checked=$((checked + 1)) checked=$((checked + 1))
printf '%s\n' "$shipped" | grep -qx "$path" \ # `case` rather than piping the list into grep -qx: under pipefail a grep
|| note_fail "The code loads '$path', but the release zip does not contain it. Committed?" # that matches can exit 141 when the producer is signalled, so a HIT becomes
# a failure. The list is small today and this loop runs once per include, so
# this also drops a fork per iteration. Newlines on both sides make it an
# exact line match, which is what -qx gave.
case $'\n'"$shipped"$'\n' in
*$'\n'"$path"$'\n'*) ;;
*) note_fail "The code loads '$path', but the release zip does not contain it. Committed?" ;;
esac
done done
if [ "$checked" = 0 ]; then if [ "$checked" = 0 ]; then
# A check that verifies nothing must say so rather than reporting success. # A check that verifies nothing must say so rather than reporting success.