diff --git a/src/command.rs b/src/command.rs index 0ccccf5..bced27d 100644 --- a/src/command.rs +++ b/src/command.rs @@ -49,20 +49,12 @@ impl Command for CommandSequence { } pub struct UnixProgram { - argv: Vec, + command: std::process::Command, } impl UnixProgram { - pub fn new(argv: Vec) -> Self { - Self { argv } - } -} - -impl Command for UnixProgram { - fn spawn(&self) -> ExitCode { - let mut argv = self.argv.clone(); + pub fn new(mut argv: Vec) -> Self { let program = argv.remove(0); - let mut command = std::process::Command::new(&program); command.args(argv); @@ -89,7 +81,10 @@ impl Command for UnixProgram { exit_code } else { - let message = format!("{}: command not found", &program); + let message = format!( + "{}: command not found", + self.command.get_program().to_str().unwrap() + ); error::print_error(message); ExitCode::not_found() }