Send only absolute paths to uu_cp (#11080)

# Description
Fixes https://github.com/nushell/nushell/issues/10832

Replaces: https://github.com/nushell/nushell/pull/10843
This commit is contained in:
Jakub Žádník
2023-11-17 01:30:57 +02:00
committed by GitHub
parent 3966c0a9fd
commit d1137cc700
3 changed files with 35 additions and 11 deletions

View File

@ -201,6 +201,14 @@ impl Command for UCp {
sources.append(&mut app_vals);
}
// Make sure to send absolute paths to avoid uu_cp looking for cwd in std::env which is not
// supported in Nushell
for src in sources.iter_mut() {
if !src.is_absolute() {
*src = nu_path::expand_path_with(&src, &cwd);
}
}
let options = uu_cp::Options {
overwrite,
reflink_mode,

View File

@ -50,11 +50,11 @@ impl Command for UMkdir {
call: &Call,
_input: PipelineData,
) -> Result<PipelineData, ShellError> {
let path = current_dir(engine_state, stack)?;
let cwd = current_dir(engine_state, stack)?;
let mut directories = call
.rest::<String>(engine_state, stack, 0)?
.into_iter()
.map(|dir| path.join(dir))
.map(|dir| nu_path::expand_path_with(dir, &cwd))
.peekable();
let is_verbose = call.has_flag("verbose");