forked from extern/nushell
Path migration part 3: $nu
paths (#13368)
# Description Part 3 of replacing `std::path` types with `nu_path` types added in #13115. This PR targets the paths listed in `$nu`. That is, the home, config, data, and cache directories.
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
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)]
|
||||
@ -46,8 +45,8 @@ impl Command for Cd {
|
||||
// user can use `cd` to recover PWD to a good state.
|
||||
let cwd = engine_state
|
||||
.cwd(Some(stack))
|
||||
.map(AbsolutePathBuf::into_std_path_buf)
|
||||
.unwrap_or(get_init_cwd());
|
||||
.ok()
|
||||
.unwrap_or_else(get_init_cwd);
|
||||
|
||||
let path_val = {
|
||||
if let Some(path) = path_val {
|
||||
@ -66,7 +65,7 @@ impl Command for Cd {
|
||||
if let Some(oldpwd) = stack.get_env_var(engine_state, "OLDPWD") {
|
||||
oldpwd.to_path()?
|
||||
} else {
|
||||
cwd
|
||||
cwd.into()
|
||||
}
|
||||
} else {
|
||||
// Trim whitespace from the end of path.
|
||||
|
@ -135,12 +135,9 @@ fn rm(
|
||||
let home: Option<String> = nu_path::home_dir().map(|path| {
|
||||
{
|
||||
if path.exists() {
|
||||
match nu_path::canonicalize_with(&path, ¤tdir_path) {
|
||||
Ok(canon_path) => canon_path,
|
||||
Err(_) => path,
|
||||
}
|
||||
nu_path::canonicalize_with(&path, ¤tdir_path).unwrap_or(path.into())
|
||||
} else {
|
||||
path
|
||||
path.into()
|
||||
}
|
||||
}
|
||||
.to_string_lossy()
|
||||
|
Reference in New Issue
Block a user