Skip to content

Fix stdin inheritance for --execute on non-Unix platforms#191

Merged
max-sixty merged 1 commit intomainfrom
fix/stdin-inheritance-non-unix
Dec 14, 2025
Merged

Fix stdin inheritance for --execute on non-Unix platforms#191
max-sixty merged 1 commit intomainfrom
fix/stdin-inheritance-non-unix

Conversation

@max-sixty
Copy link
Owner

Summary

  • Fix bug where --execute commands on non-Unix platforms (Windows) couldn't read from stdin
  • Interactive programs like vim, python -i, or claude would fail immediately with EOF
  • Root cause: execute_streaming() used Stdio::null() instead of Stdio::inherit() when no stdin content was provided

Changes

  • Add inherit_stdin parameter to execute_streaming() function
  • Non-Unix InteractiveOutput::execute() now passes true for interactive use
  • execute_command_in_worktree() passes false for non-interactive hooks
  • Added integration test that verifies stdin inheritance works

Test plan

  • Unit tests pass
  • Integration tests pass (536 tests)
  • Pre-commit hooks pass
  • Windows CI should verify the fix works on non-Unix platforms ← key validation

🤖 Generated with Claude Code

On non-Unix platforms (Windows), the --execute flag was passing None for
stdin_content to execute_streaming(), which caused stdin to be set to
Stdio::null(). This prevented interactive programs like vim, python -i,
or claude from reading user input.

The fix adds an inherit_stdin parameter to execute_streaming():
- When true and stdin_content is None, uses Stdio::inherit()
- When false and stdin_content is None, uses Stdio::null()

Call sites updated:
- InteractiveOutput::execute() (non-Unix): passes true for interactive use
- execute_command_in_worktree(): passes false for non-interactive hooks

Added test that pipes input to `wt switch --execute "cat"` and verifies
the cat command receives and outputs that input, proving stdin inheritance.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty merged commit bc05b5e into main Dec 14, 2025
17 of 18 checks passed
@max-sixty max-sixty deleted the fix/stdin-inheritance-non-unix branch December 14, 2025 19:12
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.

1 participant