From f62846b2966e0a3ffc93e718bbe44137d01c66b3 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 24 Feb 2026 08:58:23 +0000 Subject: fix migration scripts for non-interactive SSH and bash 5.3 01-fetch-events.sh: nak buffers output when stdout is not a TTY, causing it to hang silently in non-interactive SSH sessions. Wrap with 'script' to provide a pseudo-TTY, then strip the injected carriage returns and connection banner line from the output. 40-classify-actions.sh: bash 5.3 treats ${#assoc[@]} and array iteration as unbound variable errors under set -u when arrays are empty. Replace ${#assoc[@]} with explicit counters and guard array iterations with set +u/set -u. --- .../2026-01-relay-ngit-dev-migration/scripts/01-fetch-events.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'docs/archive/2026-01-relay-ngit-dev-migration/scripts/01-fetch-events.sh') diff --git a/docs/archive/2026-01-relay-ngit-dev-migration/scripts/01-fetch-events.sh b/docs/archive/2026-01-relay-ngit-dev-migration/scripts/01-fetch-events.sh index e0d6f26..7079bb9 100755 --- a/docs/archive/2026-01-relay-ngit-dev-migration/scripts/01-fetch-events.sh +++ b/docs/archive/2026-01-relay-ngit-dev-migration/scripts/01-fetch-events.sh @@ -124,7 +124,14 @@ fetch_kind() { # Use --paginate to ensure we get all events, not just first page # nak outputs one event per line (JSONL format) - if ! nak req -k "$kind" --paginate "$relay" > "$output_file" 2>/dev/null; then + # NOTE: nak buffers output when stdout is not a TTY (e.g. non-interactive SSH). + # Use 'script' to provide a pseudo-TTY so nak flushes each line immediately. + # Then strip the nak connection banner ("connecting to ...") and carriage returns + # that 'script' injects into the output stream. + if ! script -q -c "nak req -k $kind --paginate $relay" /dev/null 2>/dev/null \ + | tr -d '\r' \ + | grep -v '^connecting to ' \ + > "$output_file"; then log_error "Failed to fetch $description from $relay" return 1 fi -- cgit v1.2.3