From 3dd2f797ab41b3e44b4d990a58ee896e27059f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Sat, 26 Jan 2019 17:26:33 +1300 Subject: [PATCH] [process] Remove some more unwrap --- src/process.rs | 11 ++++++----- src/run.rs | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/process.rs b/src/process.rs index 0ead681..31b91da 100644 --- a/src/process.rs +++ b/src/process.rs @@ -1,9 +1,10 @@ +use error::Result; use pathop::PathOp; use std::collections::{HashMap, HashSet}; use std::path::PathBuf; -pub fn spawn(cmd: &Vec, updated_paths: &[PathOp], no_shell: bool) -> Process { - self::imp::Process::new(cmd, updated_paths, no_shell).expect("unable to spawn process") +pub fn spawn(cmd: &Vec, updated_paths: &[PathOp], no_shell: bool) -> Result { + self::imp::Process::new(cmd, updated_paths, no_shell).map_err(|e| e.into()) } 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, // otherwise we end up with a `COMMON_PATH` being set and other vars // being present but empty. @@ -481,7 +482,7 @@ mod tests { #[test] 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] fn test_start() { - let _ = spawn(&vec!["echo".into(), "hi".into()], vec![], true); + let _ = spawn(&vec!["echo".into(), "hi".into()], &[], true); } /* diff --git a/src/run.rs b/src/run.rs index a99d7ee..2e25306 100644 --- a/src/run.rs +++ b/src/run.rs @@ -154,7 +154,7 @@ impl ExecHandler { &self.args.cmd, ops, self.args.no_shell, - )); + )?); Ok(()) }