summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-09 22:40:24 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-09 22:40:24 -0500
commit973346c5e426d6a1b684d36ba779bf3e8f5b71b1 (patch)
treeaacdc0396a4d9f090b9e3e8bd0261218b7f79900 /src
parentf75dda7269a8ac69f16db86c6a7914bbf97a9ddf (diff)
downloadnbsh-973346c5e426d6a1b684d36ba779bf3e8f5b71b1.tar.gz
nbsh-973346c5e426d6a1b684d36ba779bf3e8f5b71b1.zip
update the environment after every pipeline
Diffstat (limited to 'src')
-rw-r--r--src/env.rs6
-rw-r--r--src/pipeline/mod.rs4
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<i32> {
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(())
}