[process] Remove some more unwrap

This commit is contained in:
Félix Saparelli 2019-01-26 17:26:33 +13:00
parent 6a23f77687
commit 3dd2f797ab
2 changed files with 7 additions and 6 deletions

View File

@ -1,9 +1,10 @@
use error::Result;
use pathop::PathOp; use pathop::PathOp;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::path::PathBuf; use std::path::PathBuf;
pub fn spawn(cmd: &Vec<String>, updated_paths: &[PathOp], no_shell: bool) -> Process { pub fn spawn(cmd: &Vec<String>, updated_paths: &[PathOp], no_shell: bool) -> Result<Process> {
self::imp::Process::new(cmd, updated_paths, no_shell).expect("unable to spawn process") self::imp::Process::new(cmd, updated_paths, no_shell).map_err(|e| e.into())
} }
pub use self::imp::Process; pub use self::imp::Process;
@ -398,7 +399,7 @@ fn collect_path_env_vars(pathops: &[PathOp]) -> Vec<(String, String)> {
} }
} }
let mut vars = vec![]; let mut vars = Vec::new();
// Only break off a common path if we have more than one unique path, // Only break off a common path if we have more than one unique path,
// otherwise we end up with a `COMMON_PATH` being set and other vars // otherwise we end up with a `COMMON_PATH` being set and other vars
// being present but empty. // being present but empty.
@ -481,7 +482,7 @@ mod tests {
#[test] #[test]
fn test_start() { fn test_start() {
let _ = spawn(&vec!["echo".into(), "hi".into()], vec![], true); let _ = spawn(&vec!["echo".into(), "hi".into()], &[], true);
} }
/* /*
@ -600,7 +601,7 @@ mod tests {
#[test] #[test]
fn test_start() { fn test_start() {
let _ = spawn(&vec!["echo".into(), "hi".into()], vec![], true); let _ = spawn(&vec!["echo".into(), "hi".into()], &[], true);
} }
/* /*

View File

@ -154,7 +154,7 @@ impl ExecHandler {
&self.args.cmd, &self.args.cmd,
ops, ops,
self.args.no_shell, self.args.no_shell,
)); )?);
Ok(()) Ok(())
} }