summaryrefslogtreecommitdiffstats
path: root/src/shell/history/mod.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-17 00:11:52 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-17 00:22:16 -0500
commit296fa4ce873c158b8c87d21db3e566c8ae365504 (patch)
tree853fdd6ff652c4be9d94830b9ee615a8ac4f8784 /src/shell/history/mod.rs
parente7d8a9f7d234cb2b8a6691c5a2e33f2b18776a3d (diff)
downloadnbsh-296fa4ce873c158b8c87d21db3e566c8ae365504.tar.gz
nbsh-296fa4ce873c158b8c87d21db3e566c8ae365504.zip
stop sending environment stuff over a pipe
sending it through the actual environment should be sufficient
Diffstat (limited to 'src/shell/history/mod.rs')
-rw-r--r--src/shell/history/mod.rs26
1 files changed, 2 insertions, 24 deletions
diff --git a/src/shell/history/mod.rs b/src/shell/history/mod.rs
index 2863cad..ad83e92 100644
--- a/src/shell/history/mod.rs
+++ b/src/shell/history/mod.rs
@@ -283,31 +283,19 @@ async fn spawn_commands(
event_w: async_std::channel::Sender<Event>,
) -> anyhow::Result<async_std::process::ExitStatus> {
let mut cmd = pty_process::Command::new(std::env::current_exe()?);
- cmd.arg("--internal-cmd-runner");
+ cmd.args(&["-c", cmdline]);
env.apply(&mut cmd);
- let (to_r, to_w) = nix::unistd::pipe2(nix::fcntl::OFlag::O_CLOEXEC)?;
let (from_r, from_w) = nix::unistd::pipe2(nix::fcntl::OFlag::O_CLOEXEC)?;
// Safety: dup2 is an async-signal-safe function
unsafe {
cmd.pre_exec(move || {
- nix::unistd::dup2(to_r, 3)?;
- nix::unistd::dup2(from_w, 4)?;
+ nix::unistd::dup2(from_w, 3)?;
Ok(())
});
}
let child = pty.spawn(cmd)?;
- nix::unistd::close(to_r)?;
nix::unistd::close(from_w)?;
- // Safety: to_w was just opened above, was not used until now, and can't
- // be used after this because from_raw_fd takes it by move
- write_env(
- unsafe { async_std::fs::File::from_raw_fd(to_w) },
- cmdline,
- env,
- )
- .await?;
-
let (read_w, read_r) = async_std::channel::unbounded();
let new_read = move || {
let read_w = read_w.clone();
@@ -394,13 +382,3 @@ async fn spawn_commands(
}
}
}
-
-async fn write_env(
- mut to_w: async_std::fs::File,
- pipeline: &str,
- env: &Env,
-) -> anyhow::Result<()> {
- to_w.write_all(&bincode::serialize(pipeline)?).await?;
- to_w.write_all(&env.as_bytes()).await?;
- Ok(())
-}