Skip to content

Instantly share code, notes, and snippets.

@paulp
Created June 9, 2015 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paulp/dfedab9256e99cfe08bb to your computer and use it in GitHub Desktop.
Save paulp/dfedab9256e99cfe08bb to your computer and use it in GitHub Desktop.
pub fn exec_slurp(cmd: &str, args: &[&OsStr]) -> String {
println!("exec_slurp({}, {:?})", cmd, args);
match Command::new(cmd).args(args).output() {
Ok(x) => String::from_utf8(x.stdout).unwrap_or(empty_string()),
_ => empty_string()
}
// Command::new(cmd)
// .args(args)
// .output()
// .and_then(|x| String::from_utf8(x.stdout))
// .unwrap_or(EMPTY_STRING);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment