diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-01-17 00:35:49 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-01-17 01:23:08 -0500 |
commit | 51b30ef54d2953a89edda966f10f150b7ef81ee5 (patch) | |
tree | 253bfd8095f15497ddb2e8104f46173d5b1092db | |
parent | 296fa4ce873c158b8c87d21db3e566c8ae365504 (diff) | |
download | nbsh-51b30ef54d2953a89edda966f10f150b7ef81ee5.tar.gz nbsh-51b30ef54d2953a89edda966f10f150b7ef81ee5.zip |
fix cd history
-rw-r--r-- | src/runner/builtins/mod.rs | 13 | ||||
-rw-r--r-- | src/runner/mod.rs | 4 |
2 files changed, 4 insertions, 13 deletions
diff --git a/src/runner/builtins/mod.rs b/src/runner/builtins/mod.rs index f181b45..19d250a 100644 --- a/src/runner/builtins/mod.rs +++ b/src/runner/builtins/mod.rs @@ -79,17 +79,6 @@ fn cd( bail!(cfg, exe, "could not find home directory"); } }; - let prev = match std::env::current_dir() { - Ok(path) => path, - Err(e) => { - bail!( - cfg, - exe, - "could not find current directory: {}", - crate::format::io_error(&e) - ); - } - }; if let Err(e) = std::env::set_current_dir(&dir) { bail!( cfg, @@ -99,8 +88,6 @@ fn cd( dir.display() ); } - // TODO - // env.set_prev_pwd(prev); async_std::process::ExitStatus::from_raw(0) } diff --git a/src/runner/mod.rs b/src/runner/mod.rs index 48d66ad..0f02ef0 100644 --- a/src/runner/mod.rs +++ b/src/runner/mod.rs @@ -211,11 +211,15 @@ async fn run_pipeline( io.set_stdout(stdout); io.set_stderr(stderr); + let pwd = env.pwd().to_path_buf(); 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.update()?; env.set_status(status); + if env.pwd() != pwd { + env.set_prev_pwd(pwd); + } Ok(()) } |