Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Unix, ripgrep ignores stdin input provided via .NET 5.0 APIs #1758

Closed
mklement0 opened this issue Dec 10, 2020 · 1 comment
Closed

On Unix, ripgrep ignores stdin input provided via .NET 5.0 APIs #1758

mklement0 opened this issue Dec 10, 2020 · 1 comment
Labels
duplicate An issue that is duplicative of another.

Comments

@mklement0
Copy link

mklement0 commented Dec 10, 2020

What version of ripgrep are you using?

ripgrep 12.1.1

How did you install ripgrep?

Homebrew on macOS, snap on Ubuntu (latest version there is 12.1.0).

What operating system are you using ripgrep on?

macOS 10.15.7
Ubuntu 18.04

Describe your bug.

rg ignores stdin input provided via .NET 5.0 APIs (no other programs I'm aware of have this problem; e.g., grep works fine). Windows is not affected.

What are the steps to reproduce the behavior?

PowerShell 7.1:

$psi = [System.Diagnostics.ProcessStartInfo] @{
  FileName = 'rg'
  RedirectStandardInput = $true
  Arguments = 'hi'
}

$ps = [System.Diagnostics.Process]::Start($psi)

$ps.StandardInput.WriteLine('hi there');
$ps.StandardInput.Close()

$ps.WaitForExit()

C# with .NET 5.0.101 SDK:

using System;
using System.Diagnostics;

namespace demo
{
  static class ConsoleApp
  {
    static void Main(string[] args)
    {
      var psi = new ProcessStartInfo { FileName = "rg", RedirectStandardInput = true, Arguments = "hi" };
      var ps = Process.Start(psi);

      ps.StandardInput.WriteLine("hi there");
      ps.StandardInput.Close();

      ps.WaitForExit();

    }

  }
}

What is the actual behavior?

rg behaves as if no stdin input had been specified and searches through the files in the current directory subtree.

What is the expected behavior?

The output should be hi there, just like when you run echo 'hi there' | rg hi from any POSIX-like shell.

However, since PowerShell [Core] is built on .NET, this command does not work in PowerShell v7.1

@BurntSushi
Copy link
Owner

This looks like a duplicate of #1741, which was fixed by #1742.

Also note that I do not recommend using Snap to install ripgrep. It has resulted in all sorts of weird problems. (Searching the issue tracker should turn up prior discussions.)

@BurntSushi BurntSushi added the duplicate An issue that is duplicative of another. label Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate An issue that is duplicative of another.
Projects
None yet
Development

No branches or pull requests

2 participants