From 973346c5e426d6a1b684d36ba779bf3e8f5b71b1 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 9 Jan 2022 22:40:24 -0500 Subject: update the environment after every pipeline --- src/env.rs | 6 +++++- src/pipeline/mod.rs | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/env.rs b/src/env.rs index fd9a047..4c461ff 100644 --- a/src/env.rs +++ b/src/env.rs @@ -109,7 +109,11 @@ impl Env { } } - pub fn update(&mut self) -> anyhow::Result<()> { + pub fn update( + &mut self, + status: std::process::ExitStatus, + ) -> anyhow::Result<()> { + self.set_status(status); self.set_current_dir(std::env::current_dir()?); self.set_vars(std::env::vars_os()); Ok(()) diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs index 7f8ac03..ebaf8e6 100644 --- a/src/pipeline/mod.rs +++ b/src/pipeline/mod.rs @@ -79,8 +79,6 @@ pub async fn run() -> anyhow::Result { let (commands, mut env) = read_data(shell_read).await?; run_commands(&commands, &mut env, &shell_write).await?; let status = *env.latest_status(); - - env.update()?; write_event(&shell_write, Event::Exit(env)).await?; if let Some(signal) = status.signal() { @@ -210,7 +208,7 @@ async fn run_pipeline( let (children, pg) = spawn_children(pipeline, env, &io)?; let status = wait_children(children, pg, env, &io, shell_write).await; set_foreground_pg(nix::unistd::getpid())?; - env.set_status(status); + env.update(status)?; Ok(()) } -- cgit v1.2.3-54-g00ecf