Skip to content

Commit a3bd42b

Browse files
Update example in pipe.md to make it compatible with windows
1 parent 578d3f7 commit a3bd42b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/std_misc/process/pipe.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ static PANGRAM: &'static str =
1313
1414
fn main() {
1515
// Spawn the `wc` command
16-
let process = match Command::new("wc")
16+
let mut cmd = if cfg!(target_family = "windows") {
17+
let mut cmd = Command::new("powershell");
18+
cmd.arg("-Command").arg("$input | Measure-Object -Line -Word -Character");
19+
cmd
20+
} else {
21+
Command::new("wc")
22+
};
23+
let process = match cmd
1724
.stdin(Stdio::piped())
1825
.stdout(Stdio::piped())
1926
.spawn() {

0 commit comments

Comments
 (0)