diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-01-17 00:05:00 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-01-17 00:05:00 -0500 |
commit | e7d8a9f7d234cb2b8a6691c5a2e33f2b18776a3d (patch) | |
tree | 84eac0ddc63e529275f48071adfdfefd1cdc1c0a /src/runner/builtins/mod.rs | |
parent | a537464a915aea2e38c62df041996b8525367bde (diff) | |
download | nbsh-e7d8a9f7d234cb2b8a6691c5a2e33f2b18776a3d.tar.gz nbsh-e7d8a9f7d234cb2b8a6691c5a2e33f2b18776a3d.zip |
simplify environment handling
this temporarily breaks cd history, will fix this soon
Diffstat (limited to 'src/runner/builtins/mod.rs')
-rw-r--r-- | src/runner/builtins/mod.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/runner/builtins/mod.rs b/src/runner/builtins/mod.rs index c345a85..f181b45 100644 --- a/src/runner/builtins/mod.rs +++ b/src/runner/builtins/mod.rs @@ -67,16 +67,17 @@ fn cd( if dir.is_empty() { ".".to_string().into() } else if dir == "-" { - env.prev_pwd().await + env.prev_pwd() } else { dir.into() } } else { let dir = env.var("HOME"); - if dir.is_empty() { + if let Some(dir) = dir { + dir.into() + } else { bail!(cfg, exe, "could not find home directory"); } - dir.into() }; let prev = match std::env::current_dir() { Ok(path) => path, @@ -98,7 +99,8 @@ fn cd( dir.display() ); } - env.set_prev_pwd(&prev).await; + // TODO + // env.set_prev_pwd(prev); async_std::process::ExitStatus::from_raw(0) } @@ -255,7 +257,7 @@ fn and( cfg.setup_command(&mut cmd); Ok(command::Child::new_wrapped(cmd.spawn(env)?)) } else { - let status = *env.latest_status(); + let status = env.latest_status(); Ok(command::Child::new_fut(async move { status })) } } @@ -267,7 +269,7 @@ fn or( ) -> anyhow::Result<command::Child> { exe.shift(); if env.latest_status().success() { - let status = *env.latest_status(); + let status = env.latest_status(); Ok(command::Child::new_fut(async move { status })) } else { let mut cmd = crate::runner::Command::new(exe, cfg.io().clone()); |