WIP: guard lookups under pipefail (test branch)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
herzogflorian 2026-10-07 15:53:32 +02:00
parent 09a2d1730f
commit d053ed6668

View File

@ -248,10 +248,11 @@ restore_hint() { # list earlier data sets next to $QC_DATA (from --rebuild-data
for d in $(ls -1dt "$QC_DATA".* 2>/dev/null); do
[[ -f "$d/universe/universe.csv" ]] || continue
if [[ $n == 0 ]]; then say " earlier data sets found (newest first):"; fi
when="$(grep -o '"setup_at": *"[^"]*"' "$d/manifest.json" 2>/dev/null | head -n 1 | sed 's/.*"\([^"]*\)"$/\1/')"
when="$(grep -o '"setup_at": *"[^"]*"' "$d/manifest.json" 2>/dev/null | head -n 1 | sed 's/.*"\([^"]*\)"$/\1/' || true)"
stocks=$(( $(wc -l < "$d/universe/universe.csv") - 1 ))
say " $d ($stocks stocks, built ${when:-?})"
n=$((n + 1)); [[ $n -ge 4 ]] && break
n=$((n + 1))
if [[ $n -ge 4 ]]; then break; fi
done
if [[ $n -gt 0 ]]; then say " restore one with: $0 data-import <folder>"; fi
}
@ -534,8 +535,9 @@ cmd_status() {
step "API $QC_API_URL"
if h="$(http_get "$QC_API_URL/health")"; then
local api_setup host_setup
api_setup="$(printf '%s' "$h" | grep -o '"setup_at":"[^"]*"' | head -n 1)"
host_setup="$(grep -o '"setup_at": *"[^"]*"' "$QC_DATA/manifest.json" 2>/dev/null | head -n 1 | tr -d ' ')"
# `|| true`: under pipefail a grep without a match would end the script silently
api_setup="$(printf '%s' "$h" | grep -o '"setup_at":"[^"]*"' | head -n 1 || true)"
host_setup="$(grep -o '"setup_at": *"[^"]*"' "$QC_DATA/manifest.json" 2>/dev/null | head -n 1 | tr -d ' ' || true)"
if [[ "$api_setup" != "$host_setup" ]]; then
warn "the running API serves a different data set than $QC_DATA (API ${api_setup:-none}, folder ${host_setup:-none}).
Run: $0 restart"