From a3bd42b41f2f676456abd4f3685c4f3f20da4277 Mon Sep 17 00:00:00 2001 From: Hosssein Date: Sun, 10 Dec 2023 17:44:46 +0330 Subject: [PATCH] Update example in pipe.md to make it compatible with windows --- src/std_misc/process/pipe.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/std_misc/process/pipe.md b/src/std_misc/process/pipe.md index fb0be0ea11..b6562cef0b 100644 --- a/src/std_misc/process/pipe.md +++ b/src/std_misc/process/pipe.md @@ -13,7 +13,14 @@ static PANGRAM: &'static str = fn main() { // Spawn the `wc` command - let process = match Command::new("wc") + let mut cmd = if cfg!(target_family = "windows") { + let mut cmd = Command::new("powershell"); + cmd.arg("-Command").arg("$input | Measure-Object -Line -Word -Character"); + cmd + } else { + Command::new("wc") + }; + let process = match cmd .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn() {