Skip to content

fix(powershell): replace stdout subshell capture with file redirect#66

Merged
tassiovirginio merged 1 commit into
tassiovirginio:mainfrom
Crqptx:fix/powershell-cd-stdout-capture
Jun 11, 2026
Merged

fix(powershell): replace stdout subshell capture with file redirect#66
tassiovirginio merged 1 commit into
tassiovirginio:mainfrom
Crqptx:fix/powershell-cd-stdout-capture

Conversation

@Crqptx

@Crqptx Crqptx commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Problem

On Windows PowerShell, pressing Enter on a folder in the TUI prints
cd <path> to the terminal instead of auto-executing it. The shell
wrapper uses $(try-rs.exe @args) to capture stdout, but after the
TUI exits raw mode and alternate screen, stdout capture can fail —
leaving the cd command printed and not evaluated.

Solution

Replace the subshell capture with PowerShell's file redirect (>).
This is a kernel-level handle redirect set up before the process
starts, so console mode changes from the TUI's raw mode cannot
interfere with it.

A unique temp file name is generated via
[System.IO.Path]::GetTempFileName() to prevent collisions when
multiple try-rs instances run concurrently.

Changes

Only one file modified — src/shell.rs. The Rust binary is
untouched. This is purely a PowerShell wrapper fix, no impact on
Linux, macOS, or other shells (bash, zsh, fish, nushell).

How to test?

  1. Run try-rs --setup power-shell and reload profile
  2. Open the TUI with try-rs, select a folder, press Enter
  3. Confirm it automatically cds into the selected folder
  4. Open two terminal windows, run try-rs in both simultaneously
    — both should work without errors

The PowerShell wrapper used $(try-rs.exe @Args) to capture stdout,
but on Windows the TUI's raw mode and alternate screen interactions
can cause this to fail, leaving the "cd" command printed to the
terminal instead of being evaluated.

Fix this by using PowerShell's file redirect (>) instead. This is a
kernel-level handle redirect set up before the process starts, so
console mode changes from the TUI cannot affect it.

Use [System.IO.Path]::GetTempFileName() to generate unique temp
file names, preventing collisions when multiple try-rs instances
run concurrently.
@tassiovirginio tassiovirginio merged commit 9f6649f into tassiovirginio:main Jun 11, 2026
2 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.

2 participants