Skip to content

Commit 4cd57c9

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 90a4544 commit 4cd57c9

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
@@ -544,23 +544,31 @@ _compose_run_with_summary() {
544544

545545
local _compose_log
546546
_compose_log=$(mktemp)
547+
trap 'rm -f "$_compose_log"' INT TERM
547548

548549
local _rc=0
549550
docker compose --progress quiet "$@" >"$_compose_log" 2>&1 || _rc=$?
550551

551552
if (( _rc == 0 )); then
552553
success "${_verb} — done"
553554
rm -f "$_compose_log"
555+
trap - INT TERM
554556
return 0
555557
fi
556558

557559
log_error "${_verb} failed:"
558-
grep -iE 'error|unhealthy|failed|dependency' "$_compose_log" \
560+
local _surfaced
561+
_surfaced=$(grep -iE 'error|unhealthy|failed|dependency' "$_compose_log" \
559562
| sed 's/^/ /' \
560-
| head -20 \
561-
|| warn "(no error keywords matched in compose log)"
563+
| head -20 || true)
564+
if [[ -n "$_surfaced" ]]; then
565+
printf '%s\n' "$_surfaced"
566+
else
567+
warn "(no error keywords matched in compose log)"
568+
fi
562569
echo ""
563570
log "Full compose output: $_compose_log"
571+
trap - INT TERM
564572
return "$_rc"
565573
}
566574

0 commit comments

Comments
 (0)