diff --git a/src/command.rs b/src/command.rs index ac5479e..770b989 100644 --- a/src/command.rs +++ b/src/command.rs @@ -19,7 +19,7 @@ impl ExitCode { } pub trait Command { - fn spawn(&self) -> ExitCode; + fn spawn(&mut self) -> ExitCode; } pub struct CommandSequence { @@ -46,11 +46,11 @@ impl CommandSequence { } impl Command for CommandSequence { - fn spawn(&self) -> ExitCode { + fn spawn(&mut self) -> ExitCode { let mut exit_code = self.command.spawn(); if self.next_command.is_some() { - exit_code = self.next_command.as_ref().unwrap().spawn(); + exit_code = self.next_command.as_mut().unwrap().spawn(); } exit_code @@ -75,7 +75,13 @@ impl Command for UnixProgram { let mut command = std::process::Command::new(&program); command.args(argv); - let handle = command.spawn(); + Self { command } + } +} + +impl Command for UnixProgram { + fn spawn(&mut self) -> ExitCode { + let handle = self.command.spawn(); if handle.is_ok() { let exit_code = handle