From 020c5453a5880257c87949030550d24c596f5c8d Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Mon, 23 Nov 2020 08:25:20 +0200 Subject: cli: fix stdin detection for Powershell on Unix It seems that PowerShell uses sockets instead of FIFOs to redirect the output between commands. So add `is_socket` to our `is_readable_stdin` check. This seems unlikely to cause problems and it probably more generally correct than what we had before. In theory, it could cause problems if it produces false positives, in which case, ripgrep will try to read stdin when it should search the current working directory. (And this usually winds up manifesting as ripgrep blocking forever.) But, if the stdin handle reports itself as a socket, then it seems like we should read it. Fixes #1741, Closes #1742 --- CHANGELOG.md | 2 ++ crates/cli/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d102b0df..af9bbb2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ Bug fixes: * [BUG #1277](https://github.com/BurntSushi/ripgrep/issues/1277): Document cygwin path translation behavior in the FAQ. +* [BUG #1741](https://github.com/BurntSushi/ripgrep/issues/1741): + Fix stdin detection when using PowerShell in UNIX environments. 12.1.1 (2020-05-29) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 452ea141..9fe1cf3c 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -210,7 +210,7 @@ pub fn is_readable_stdin() -> bool { Err(_) => return false, Ok(md) => md.file_type(), }; - ft.is_file() || ft.is_fifo() + ft.is_file() || ft.is_fifo() || ft.is_socket() } #[cfg(windows)] -- cgit v1.2.3