From 472fdcbc4d159e3c651a9388e65b327bf356087c Mon Sep 17 00:00:00 2001 From: jknapp Date: Wed, 21 Oct 2026 16:48:17 -0700 Subject: [PATCH] fix(pkg-cache): no `| while read` pipelines under pipefail Shell-Checks' structural scan (scripts/tests/lsphp-info-probe.test.sh) flagged two `cmd | while read` loops in pkg-cache-repos.sh restore. Read the lists with mapfile from a process substitution instead, so there is no pipeline. The test now passes locally (36/0), shellcheck is clean, and the restore tests (new cache-referencing file removed, leftover reference -> FATAL) behave as before. Co-Authored-By: Claude Opus 5.5 --- scripts/pkg-cache-repos.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/pkg-cache-repos.sh b/scripts/pkg-cache-repos.sh index fb83c55..37580a0 100755 --- a/scripts/pkg-cache-repos.sh +++ b/scripts/pkg-cache-repos.sh @@ -83,13 +83,17 @@ created() { printf '%s\n' "$1" >> "$STATE/created"; } if [ "$MODE" = restore ]; then [ -d "$STATE" ] || exit 0 host=$(cat "$STATE/host") - (cd "$STATE/orig" && find . -type f) | while read -r rel; do + # mapfile from a process substitution, not `cmd | while read`: no pipeline, + # so nothing for pipefail to misreport (scripts/tests/lsphp-info-probe.test.sh). + mapfile -t saved < <(cd "$STATE/orig" && find . -type f) + for rel in "${saved[@]}"; do cat "$STATE/orig/$rel" > "/${rel#./}" done while read -r f; do [ -n "$f" ] && rm -f -- "$f"; done < "$STATE/created" # A repo/apt file that appeared during this RUN and still names the cache # (e.g. written by a package from the rewritten repos) is removed too. - repo_files | while read -r f; do + mapfile -t current < <(repo_files) + for f in "${current[@]}"; do if ! grep -qxF -- "$f" "$STATE/manifest" && grep -qF -- "$host" "$f"; then echo "pkg-cache-repos: removing new file that references the cache: $f" rm -f -- "$f" -- 2.52.0