mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
don't join paths to cwd ever in calls to external functions (#5180)
This is a follow-up to #5131, since I don't personally like the way it worked.
This commit is contained in:
@ -73,3 +73,16 @@ where
|
||||
|
||||
expand_path(path)
|
||||
}
|
||||
|
||||
/// Resolve similarly to other shells - tilde is expanded, and ndot path components are expanded.
|
||||
///
|
||||
/// This function will take a leading tilde path component, and expand it to the user's home directory;
|
||||
/// it will also expand any path elements consisting of only dots into the correct number of `..` path elements.
|
||||
/// It does not touch the system at all, except for getting the home directory of the current user.
|
||||
pub fn expand_path_for_external_programs<P>(path: P) -> PathBuf
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let path = expand_tilde(path);
|
||||
expand_ndots(path)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ mod helpers;
|
||||
mod tilde;
|
||||
mod util;
|
||||
|
||||
pub use expansions::{canonicalize_with, expand_path_with};
|
||||
pub use expansions::{canonicalize_with, expand_path_for_external_programs, expand_path_with};
|
||||
pub use helpers::{config_dir, home_dir};
|
||||
pub use tilde::expand_tilde;
|
||||
pub use util::trim_trailing_slash;
|
||||
|
Reference in New Issue
Block a user