Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/ten-mangos-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@repo/sandbox-container": patch
"@cloudflare/sandbox": patch
---

fix: preserve newlines in heredoc commands for exec()
6 changes: 3 additions & 3 deletions .github/workflows/pkg-pr-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ permissions:
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- '!**/*.md'
- '!.changeset/**'
#paths:
# - '!**/*.md'
# - '!.changeset/**'


jobs:
Expand Down
8 changes: 6 additions & 2 deletions packages/sandbox-container/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,9 @@ export class Session {
script += ` PREV_DIR=$(pwd)\n`;
script += ` if cd ${safeCwd}; then\n`;
script += ` # Execute command with prefixed streaming via process substitution\n`;
script += ` { ${command}; } > >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x01\\x01\\x01%s\\n' "$line"; done >> "$log") 2> >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x02\\x02\\x02%s\\n' "$line"; done >> "$log")\n`;
script += ` {\n`;
script += `${command}\n`;
script += ` } > >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x01\\x01\\x01%s\\n' "$line"; done >> "$log") 2> >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x02\\x02\\x02%s\\n' "$line"; done >> "$log")\n`;
script += ` EXIT_CODE=$?\n`;
script += ` # Restore directory\n`;
script += ` cd "$PREV_DIR"\n`;
Expand All @@ -708,7 +710,9 @@ export class Session {
script += ` fi\n`;
} else {
script += ` # Execute command with prefixed streaming via process substitution\n`;
script += ` { ${command}; } > >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x01\\x01\\x01%s\\n' "$line"; done >> "$log") 2> >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x02\\x02\\x02%s\\n' "$line"; done >> "$log")\n`;
script += ` {\n`;
script += `${command}\n`;
script += ` } > >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x01\\x01\\x01%s\\n' "$line"; done >> "$log") 2> >(while IFS= read -r line || [[ -n "$line" ]]; do printf '\\x02\\x02\\x02%s\\n' "$line"; done >> "$log")\n`;
script += ` EXIT_CODE=$?\n`;
}

Expand Down