Skip to content

Commit 0fc56ca

Browse files
yasinBursaliclaude
andcommitted
fix(dream-cli): _compose_run_with_summary SIGINT cleanup + zero-match fallback
Ctrl-C during a compose operation leaked the mktemp log because there was no INT/TERM trap. Add trap 'rm -f "$_compose_log"' INT TERM after mktemp and restore with trap - INT TERM before each return. The grep | sed | head pipeline exit code is 0 even when grep finds no matches (head exits 0 on empty input), so the || warn fallback never fired. Capture the pipeline output to _surfaced and branch on non-empty to decide between printing matches or emitting the "no error keywords matched" hint. Correct under set -e today, pipefail-safe going forward. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent edb2431 commit 0fc56ca

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

dream-server/dream-cli

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,23 +568,31 @@ _compose_run_with_summary() {
568568

569569
local _compose_log
570570
_compose_log=$(mktemp)
571+
trap 'rm -f "$_compose_log"' INT TERM
571572

572573
local _rc=0
573574
docker compose --progress quiet "$@" >"$_compose_log" 2>&1 || _rc=$?
574575

575576
if (( _rc == 0 )); then
576577
success "${_verb} — done"
577578
rm -f "$_compose_log"
579+
trap - INT TERM
578580
return 0
579581
fi
580582

581583
log_error "${_verb} failed:"
582-
grep -iE 'error|unhealthy|failed|dependency' "$_compose_log" \
584+
local _surfaced
585+
_surfaced=$(grep -iE 'error|unhealthy|failed|dependency' "$_compose_log" \
583586
| sed 's/^/ /' \
584-
| head -20 \
585-
|| warn "(no error keywords matched in compose log)"
587+
| head -20 || true)
588+
if [[ -n "$_surfaced" ]]; then
589+
printf '%s\n' "$_surfaced"
590+
else
591+
warn "(no error keywords matched in compose log)"
592+
fi
586593
echo ""
587594
log "Full compose output: $_compose_log"
595+
trap - INT TERM
588596
return "$_rc"
589597
}
590598

0 commit comments

Comments
 (0)