Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Dec 23, 2025

Summary

This PR fixes issue #25 where commands with quoted strings (e.g., echo "hello") would not show their output when using screen isolation in attached mode.

Problem

When running:

$ --isolated screen --verbose -- echo "hello"

The output would only show [screen is terminating] without the expected "hello" output, even though the command executed successfully with exit code 0.

Root Cause

The code used execSync with a constructed shell command string where each argument was wrapped in double quotes. When the command itself contained double quotes, this caused shell parsing errors due to nested quoting:

// Broken approach:
execSync(`screen ${screenArgs.map((a) => `"${a}"`).join(' ')}`, { ... });

// For echo "hello" this became:
// screen "-dmS" "session" "/bin/sh" "-c" "(echo "hello") 2>&1 | tee "...log""
// The nested quotes break shell parsing!

Solution

Use spawnSync with an array of arguments instead of execSync with a string. Node.js/Bun's spawnSync handles argument quoting correctly by passing arguments directly to the process without shell interpretation.

// Fixed approach:
const result = spawnSync('screen', screenArgs, { stdio: 'inherit' });

Changes

  • src/lib/isolation.js: Replace execSync with spawnSync for screen commands
  • test/isolation.test.js: Add 2 regression tests for quoted string commands
  • docs/case-studies/issue-25/: Add case study documentation with root cause analysis
  • experiments/: Add debug experiments used during investigation
  • package.json: Bump version to 0.7.3

Test Results

All 25 isolation tests pass, including the 2 new regression tests:

✓ should capture output from commands with quoted strings (issue #25)
✓ should capture output from commands with complex quoted strings

Fixes #25

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #25
@konard konard self-assigned this Dec 23, 2025
This fixes issue #25 where commands with quoted strings (e.g., echo "hello")
would not show their output when using screen isolation.

Root cause: The code used execSync with a constructed shell command string
where each argument was wrapped in double quotes. When the command itself
contained double quotes, this caused shell parsing errors due to nested
quoting.

Solution: Use spawnSync with an array of arguments instead of execSync
with a string. Node.js/Bun's spawnSync handles argument quoting correctly
by passing arguments directly to the process without shell interpretation.

Changes:
- src/lib/isolation.js: Replace execSync with spawnSync for screen commands
- test/isolation.test.js: Add regression tests for quoted string commands
- docs/case-studies/issue-25/: Add case study documentation
- experiments/: Add debug experiments used during investigation

Fixes #25

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] We don't get Hello output from $ --isolated screen --verbose -- echo "hello" command fix: Screen isolation output not captured for quoted commands Dec 23, 2025
@konard konard marked this pull request as ready for review December 23, 2025 21:07
@konard
Copy link
Member Author

konard commented Dec 23, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $7.380758 USD
  • Calculated by Anthropic: $5.012937 USD
  • Difference: $-2.367821 (-32.08%)
    📎 Log file uploaded as GitHub Gist (814KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 4bd212a into main Dec 23, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

We don't get Hello output from $ --isolated screen --verbose -- echo "hello" command

2 participants