Skip to content

Why can't ripgrep search the output of a Write-Host command on Windows? #2892

Answered by ltrzesniewski
Saya47 asked this question in Q&A
Discussion options

You must be logged in to vote
  • Write-Host writes directly to PowerShell (the host), skipping the pipeline (stdin/stdout).

    The Write-Host cmdlet's primary purpose is to produce for-(host)-display-only output, such as printing colored text like when prompting the user for input in conjunction with Read-Host. Write-Host uses the ToString() method to write the output. By contrast, to output data to the pipeline, use Write-Output or implicit output.

  • Write-Output writes to the pipeline (stdout), and echo is an alias to it.

    Write-Output sends objects to the primary pipeline, also known as the success stream. To send error objects to the error stream, use Write-Error.

=> ripgrep can't work with Write-Host, as it does…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2891 on September 14, 2024 13:36.