fix: cloud-init streaming script bash syntax error (#1737)

.join("; ") produced invalid bash: &; after background command,
do; after for, then; after if. Use newline-joined string instead.

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
A 2026-02-22 12:05:54 -08:00 committed by GitHub
parent b50b27141c
commit dc21fa223b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 14 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@openrouter/spawn",
"version": "0.6.9",
"version": "0.6.10",
"type": "module",
"bin": {
"spawn": "cli.js"

View file

@ -762,19 +762,17 @@ export async function waitForCloudInit(
// Stream cloud-init output so the user sees progress in real time
logStep("Streaming cloud-init output (timeout: 5min)...");
const remoteScript = [
'tail -f /var/log/cloud-init-output.log 2>/dev/null &',
'TAIL_PID=$!',
'for i in $(seq 1 150); do',
' if [ -f /root/.cloud-init-complete ]; then',
' kill $TAIL_PID 2>/dev/null; wait $TAIL_PID 2>/dev/null',
' echo ""; echo "--- cloud-init complete ---"; exit 0',
' fi',
' sleep 2',
'done',
'kill $TAIL_PID 2>/dev/null; wait $TAIL_PID 2>/dev/null',
'echo ""; echo "--- cloud-init timed out ---"; exit 1',
].join("; ");
const remoteScript =
'tail -f /var/log/cloud-init-output.log 2>/dev/null & TAIL_PID=$!\n' +
'for i in $(seq 1 150); do\n' +
' if [ -f /root/.cloud-init-complete ]; then\n' +
' kill $TAIL_PID 2>/dev/null; wait $TAIL_PID 2>/dev/null\n' +
' echo ""; echo "--- cloud-init complete ---"; exit 0\n' +
' fi\n' +
' sleep 2\n' +
'done\n' +
'kill $TAIL_PID 2>/dev/null; wait $TAIL_PID 2>/dev/null\n' +
'echo ""; echo "--- cloud-init timed out ---"; exit 1';
try {
const proc = Bun.spawn(