Navigation Menu

Skip to content

Commit

Permalink
Rollup merge of rust-lang#55754 - spastorino:fix-process-output-docs,…
Browse files Browse the repository at this point in the history
… r=alexcrichton

Avoid converting bytes to UTF-8 strings to print, just pass bytes to stdout/err

r? @nikomatsakis
  • Loading branch information
pietroalbini committed Nov 12, 2018
2 parents d1af662 + 3b3b60c commit 1449acc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/libstd/process.rs
Expand Up @@ -764,14 +764,15 @@ impl Command {
///
/// ```should_panic
/// use std::process::Command;
/// use std::io::{self, Write};
/// let output = Command::new("/bin/cat")
/// .arg("file.txt")
/// .output()
/// .expect("failed to execute process");
///
/// println!("status: {}", output.status);
/// println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
/// println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
/// io::stdout().write_all(&output.stdout).unwrap();
/// io::stderr().write_all(&output.stderr).unwrap();
///
/// assert!(output.status.success());
/// ```
Expand Down Expand Up @@ -951,14 +952,16 @@ impl Stdio {
///
/// ```no_run
/// use std::process::{Command, Stdio};
/// use std::io::{self, Write};
///
/// let output = Command::new("rev")
/// .stdin(Stdio::inherit())
/// .stdout(Stdio::piped())
/// .output()
/// .expect("Failed to execute command");
///
/// println!("You piped in the reverse of: {}", String::from_utf8_lossy(&output.stdout));
/// print!("You piped in the reverse of: ");
/// io::stdout().write_all(&output.stdout).unwrap();
/// ```
#[stable(feature = "process", since = "1.0.0")]
pub fn inherit() -> Stdio { Stdio(imp::Stdio::Inherit) }
Expand Down

0 comments on commit 1449acc

Please sign in to comment.