mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
mv: allow dest with slash when using --update
This commit is contained in:
parent
546201bd00
commit
1c6317af76
2 changed files with 19 additions and 1 deletions
|
@ -341,7 +341,11 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()>
|
||||||
|
|
||||||
let target_is_dir = target.is_dir();
|
let target_is_dir = target.is_dir();
|
||||||
|
|
||||||
if path_ends_with_terminator(target) && !target_is_dir && !opts.no_target_dir {
|
if path_ends_with_terminator(target)
|
||||||
|
&& !target_is_dir
|
||||||
|
&& !opts.no_target_dir
|
||||||
|
&& opts.update != UpdateMode::ReplaceIfOlder
|
||||||
|
{
|
||||||
return Err(MvError::FailedToAccessNotADirectory(target.quote().to_string()).into());
|
return Err(MvError::FailedToAccessNotADirectory(target.quote().to_string()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -905,6 +905,20 @@ fn test_mv_update_option() {
|
||||||
assert!(!at.file_exists(file_b));
|
assert!(!at.file_exists(file_b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_mv_update_with_dest_ending_with_slash() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
let source = "source";
|
||||||
|
let dest = "destination/";
|
||||||
|
|
||||||
|
at.mkdir("source");
|
||||||
|
|
||||||
|
ucmd.arg("--update").arg(source).arg(dest).succeeds();
|
||||||
|
|
||||||
|
assert!(!at.dir_exists(source));
|
||||||
|
assert!(at.dir_exists(dest));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mv_arg_update_none() {
|
fn test_mv_arg_update_none() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue