diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-01-15 01:20:43 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-01-15 01:21:33 -0500 |
commit | 3adc8b67354a492f4bceed4b9bf1ec5c000c2056 (patch) | |
tree | 33b6e041c8b1e1962592b1ce8c7a5b36c4ab1d8e /src/env.rs | |
parent | 35a7db590aab2c8d1508115a490678fce6376000 (diff) | |
download | nbsh-3adc8b67354a492f4bceed4b9bf1ec5c000c2056.tar.gz nbsh-3adc8b67354a492f4bceed4b9bf1ec5c000c2056.zip |
set default SHELL and TERM for subprocesses
Diffstat (limited to 'src/env.rs')
-rw-r--r-- | src/env.rs | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -20,13 +20,19 @@ pub struct V0 { } impl Env { - pub fn new() -> Self { - Self::V0(V0 { + pub fn new() -> anyhow::Result<Self> { + let mut vars: std::collections::HashMap< + std::ffi::OsString, + std::ffi::OsString, + > = std::env::vars_os().collect(); + vars.insert("SHELL".into(), std::env::current_exe()?.into()); + vars.insert("TERM".into(), "screen".into()); + Ok(Self::V0(V0 { idx: 0, latest_status: std::process::ExitStatus::from_raw(0), - pwd: std::env::current_dir().unwrap(), - vars: std::env::vars_os().collect(), - }) + pwd: std::env::current_dir()?, + vars, + })) } pub fn idx(&self) -> usize { |