Use AbsolutePathBuf::into_std_path_buf

This commit is contained in:
Ian Manske 2024-07-08 17:39:48 -07:00
parent c8dd42c0a7
commit 6c859cf68f
2 changed files with 4 additions and 2 deletions

View File

@ -1,3 +1,4 @@
use nu_path::AbsolutePathBuf;
use nu_protocol::{
engine::{EngineState, Stack},
Range, ShellError, Span, Value,
@ -15,7 +16,7 @@ pub fn get_init_cwd() -> PathBuf {
pub fn get_guaranteed_cwd(engine_state: &EngineState, stack: &Stack) -> PathBuf {
engine_state
.cwd(Some(stack))
.map(Into::into)
.map(AbsolutePathBuf::into_std_path_buf)
.unwrap_or(crate::util::get_init_cwd())
}

View File

@ -1,5 +1,6 @@
use nu_cmd_base::util::get_init_cwd;
use nu_engine::command_prelude::*;
use nu_path::AbsolutePathBuf;
use nu_utils::filesystem::{have_permission, PermissionResult};
#[derive(Clone)]
@ -45,7 +46,7 @@ impl Command for Cd {
// user can use `cd` to recover PWD to a good state.
let cwd = engine_state
.cwd(Some(stack))
.map(Into::into)
.map(AbsolutePathBuf::into_std_path_buf)
.unwrap_or(get_init_cwd());
let path_val = {