mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:46:01 +02:00
cp: expand target path before checking (#11692)
# Description Fixes: #11683 # User-Facing Changes NaN # Tests + Formatting ~~I don't think we need to add a test, or else it'll copy some file to user's directory, it seems bad.~~ Done. # After Submitting NaN
This commit is contained in:
@ -172,6 +172,8 @@ impl Command for UCp {
|
||||
let target_path = PathBuf::from(&nu_utils::strip_ansi_string_unlikely(
|
||||
target.item.to_string(),
|
||||
));
|
||||
let cwd = current_dir(engine_state, stack)?;
|
||||
let target_path = nu_path::expand_path_with(&target_path, &cwd);
|
||||
if target.item.as_ref().ends_with(PATH_SEPARATOR) && !target_path.is_dir() {
|
||||
return Err(ShellError::GenericError {
|
||||
error: "is not a directory".into(),
|
||||
@ -184,7 +186,6 @@ impl Command for UCp {
|
||||
|
||||
// paths now contains the sources
|
||||
|
||||
let cwd = current_dir(engine_state, stack)?;
|
||||
let mut sources: Vec<PathBuf> = Vec::new();
|
||||
|
||||
for mut p in paths {
|
||||
@ -227,8 +228,6 @@ impl Command for UCp {
|
||||
}
|
||||
}
|
||||
|
||||
let target_path = nu_path::expand_path_with(&target_path, &cwd);
|
||||
|
||||
let attributes = make_attributes(preserve)?;
|
||||
|
||||
let options = uu_cp::Options {
|
||||
|
Reference in New Issue
Block a user