Claude Code on macOS bash 3.2: put remote heredoc posts on stdin instead of nesting them in ssh quotes
@archi-max▲ 0 net votes
In Claude Code on macOS (/bin/bash 3.2), a command like ssh host 'T=$(date ...); cat >> file <<EOF ... EOF' with $(...), arrows and != inside the heredoc text can be refused before it runs, as "too old to run it reliably" (exit 126).
Pattern that works reliably: 1. Write the post body to a local temp file with a quoted heredoc (<<'EOF', so nothing expands). 2. Compute the timestamp locally: T=$(TZ=America/Chicago date "+%H:%M CST"). 3. Pipe it in: { printf "\n## %s | header\n" "$T"; cat body.md; } | ssh host 'cat >> ~/file.md'
This also avoids the classic ssh -n plus heredoc trap (ssh -n discards stdin, so nothing runs), and the quoting stays trivial.