diff options
| author | Patrick Decat <pdecat@gmail.com> | 2023-03-15 00:15:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-14 23:15:39 +0000 |
| commit | efd2230eba28cea6265288315e80ca1be96783c2 (patch) | |
| tree | 1c9595b5fbff144b501b4b749698013fa35f67c1 /src | |
| parent | Fixes a bug on windows (#780) (diff) | |
| download | atuin-efd2230eba28cea6265288315e80ca1be96783c2.zip | |
Prefer PWD environment variable over cwd if available to better support symbolic links (#783)
Diffstat (limited to '')
| -rw-r--r-- | src/command/client/history.rs | 6 | ||||
| -rw-r--r-- | src/command/client/search.rs | 7 |
2 files changed, 5 insertions, 8 deletions
diff --git a/src/command/client/history.rs b/src/command/client/history.rs index 7382eba6..8735123e 100644 --- a/src/command/client/history.rs +++ b/src/command/client/history.rs @@ -5,6 +5,7 @@ use std::{ time::Duration, }; +use atuin_common::utils; use clap::Subcommand; use eyre::Result; use runtime_format::{FormatKey, FormatKeyError, ParsedFmt}; @@ -181,8 +182,7 @@ impl Cmd { // It's better for atuin to silently fail here and attempt to // store whatever is ran, than to throw an error to the terminal - let cwd = env::current_dir() - .map_or_else(|_| String::new(), |dir| dir.display().to_string()); + let cwd = utils::get_current_dir(); let h = History::new(chrono::Utc::now(), command, cwd, -1, -1, None, None); @@ -240,7 +240,7 @@ impl Cmd { None }; let cwd = if *cwd { - Some(env::current_dir()?.display().to_string()) + Some(utils::get_current_dir()) } else { None }; diff --git a/src/command/client/search.rs b/src/command/client/search.rs index 3098267a..8d0e1de4 100644 --- a/src/command/client/search.rs +++ b/src/command/client/search.rs @@ -1,3 +1,4 @@ +use atuin_common::utils; use chrono::Utc; use clap::Parser; use eyre::Result; @@ -137,11 +138,7 @@ async fn run_non_interactive( db: &mut impl Database, ) -> Result<usize> { let dir = if cwd.as_deref() == Some(".") { - let current = std::env::current_dir()?; - let current = current.as_os_str(); - let current = current.to_str().unwrap(); - - Some(current.to_owned()) + Some(utils::get_current_dir()) } else { cwd }; |
