Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/std_misc/process/pipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,32 @@ process via pipes.

```rust,ignore
use std::io::prelude::*;
use std::process::{Command, Stdio};
use std::process::Stdio;

static PANGRAM: &'static str =
"the quick brown fox jumped over the lazy dog\n";

fn main() {
// Spawn the `wc` command
let process = match Command::new("wc")
#[cfg(target_family = "unix")]
mod platform {
use std::process::Command;
pub fn wc() -> Box<Command> {
let process = Command::new("wc");
Box::new(process)
}
}
#[cfg(target_family = "windows")]
mod platform {
use std::process::Command;
pub fn wc() -> Box<Command> {
let mut process = Command::new("powershell");
process.arg("-Command").arg("$input | Measure-Object -Line -Word -Character");
Box::new(process)
}
}

let process = match platform::wc()
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn() {
Expand Down