summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoey Darwish Dror <rodarwis@microsoft.com>2020-11-23 08:25:20 +0200
committerAndrew Gallant <jamslam@gmail.com>2020-11-23 10:23:34 -0500
commit020c5453a5880257c87949030550d24c596f5c8d (patch)
tree7fc77d25a3cefd5bcb9ae5f69672da31e7ad6696
parent873abecbf1c4fbac2e070ac33a25e7a23fea6700 (diff)
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
-rw-r--r--CHANGELOG.md2
-rw-r--r--crates/cli/src/lib.rs2
2 files changed, 3 insertions, 1 deletions
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)]