diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-24 08:58:23 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-24 08:58:23 +0000 |
| commit | f62846b2966e0a3ffc93e718bbe44137d01c66b3 (patch) | |
| tree | cac224e3f330fefca79c728ed05235b6bb29d98f /docs/archive/2026-01-relay-ngit-dev-migration/scripts/01-fetch-events.sh | |
| parent | c54ce061d6d278cce8362d5af085808ca60c239b (diff) | |
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.
Diffstat (limited to 'docs/archive/2026-01-relay-ngit-dev-migration/scripts/01-fetch-events.sh')
| -rwxr-xr-x | docs/archive/2026-01-relay-ngit-dev-migration/scripts/01-fetch-events.sh | 9 |
1 files changed, 8 insertions, 1 deletions
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() { | |||
| 124 | 124 | ||
| 125 | # Use --paginate to ensure we get all events, not just first page | 125 | # Use --paginate to ensure we get all events, not just first page |
| 126 | # nak outputs one event per line (JSONL format) | 126 | # nak outputs one event per line (JSONL format) |
| 127 | if ! nak req -k "$kind" --paginate "$relay" > "$output_file" 2>/dev/null; then | 127 | # NOTE: nak buffers output when stdout is not a TTY (e.g. non-interactive SSH). |
| 128 | # Use 'script' to provide a pseudo-TTY so nak flushes each line immediately. | ||
| 129 | # Then strip the nak connection banner ("connecting to ...") and carriage returns | ||
| 130 | # that 'script' injects into the output stream. | ||
| 131 | if ! script -q -c "nak req -k $kind --paginate $relay" /dev/null 2>/dev/null \ | ||
| 132 | | tr -d '\r' \ | ||
| 133 | | grep -v '^connecting to ' \ | ||
| 134 | > "$output_file"; then | ||
| 128 | log_error "Failed to fetch $description from $relay" | 135 | log_error "Failed to fetch $description from $relay" |
| 129 | return 1 | 136 | return 1 |
| 130 | fi | 137 | fi |