fix(powershell): replace stdout subshell capture with file redirect#66
Merged
tassiovirginio merged 1 commit intoJun 11, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows PowerShell, pressing Enter on a folder in the TUI prints
cd <path>to the terminal instead of auto-executing it. The shellwrapper uses
$(try-rs.exe @args)to capture stdout, but after theTUI exits raw mode and alternate screen, stdout capture can fail —
leaving the
cdcommand 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 whenmultiple
try-rsinstances run concurrently.Changes
Only one file modified —
src/shell.rs. The Rust binary isuntouched. This is purely a PowerShell wrapper fix, no impact on
Linux, macOS, or other shells (bash, zsh, fish, nushell).
How to test?
try-rs --setup power-shelland reload profiletry-rs, select a folder, press Entercds into the selected foldertry-rsin both simultaneously— both should work without errors