BurntSushi / ripgrep

ripgrep recursively searches directories for a regex pattern while respecting your gitignore
The Unlicense
48.83k stars 2.01k forks source link

PowerShell Write-Host unexpected behavior #2891

Closed Saya47 closed 2 months ago

Saya47 commented 2 months ago

Please tick this box to confirm you have reviewed the above.

What version of ripgrep are you using?

ripgrep 14.1.1 (rev 4649aa9700)

How did you install ripgrep?

scoop

What operating system are you using ripgrep on?

Windows 11, PowerShell 7.4.2

Describe your bug.

ripgrep does not read stdin from Write-Host

https://github.com/BurntSushi/ripgrep/issues/643

What are the steps to reproduce the behavior?

02:05 ~ ❯ echo hello | rg y

02:06 ~ ✖ echo hello | rg he hello

02:06 ~ ❯ write-host hello | rg y hello

02:06 ~ ✖ write-host hello | rg he hello

02:07 ~ ✖

What is the actual behavior?

ripgrep does not read stdin from Write-Host

What is the expected behavior?

ripgrep should work on Write-Host

BurntSushi commented 2 months ago

What happens if you do rg y -?

My guess is that Write-Host isn't writing to stdout. Which means this is expected behavior. But I'm not familiar with Windows too much and I don't know what Write-Host is. Maybe you can do some debugging by comparing with other tools.

ltrzesniewski commented 2 months ago

=> ripgrep can't work with Write-Host, as it doesn't send its value to stdout. You can see this behavior with how ripgrep adds color to its output:

image