Console.IsInputRedirected returns true on git bash when there is no redirected input
#95,079 opened on 2023年11月21日
Repository metrics
- Stars
- (17,886 stars)
- PR merge metrics
- (平均マージ 12d 11h) (30d で 661 merged PRs)
説明
Description
Hi,
I have command-line tool (roslynator) that tries to read redirected input and use it as an input for the program (in my case it's a list of solutions to be analyzed).
Example code:
get-solution-paths | roslynator analyze
For this purpose I use Console.IsInputRedirected which works fine on Windows Terminal with Powershell.
The problem is that when I run just roslynator analyze on git bash (git-bash.exe) Console.IsInputRedirected returns true and then the execution is blocked when program tries to read input from console (when there is no redirected input):
Thanks for help in advance.
Reproduction Steps
dotnet tool install roslynator.dotnet.cli -g --version 0.7.2- run
git-bash.exefrom git installation folder - from git bash run
roslynator analyze <PATH-TO-SOLUTION> -v diag - The execution is blocked when program tries to read redirected input
Expected behavior
Console.IsInputRedirected should return false when there is no redirected input
Actual behavior
Console.IsInputRedirected returns true on git bash when there is no redirected input.
Regression?
No response
Known Workarounds
Set timeout for a task that tries to read redirected input:
Task<IEnumerable<string>> task = ConsoleHelpers.ReadRedirectedInputAsLines();
if (task.Wait(TimeSpan.FromMilliseconds(1000)))
{
}
Configuration
- Windows 10 Pro x64
- .NET SDK 8.0.100
- git 2.42.0.windows.2
Other information
No response