mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
mv: support the case mkdir a && mv a e/
This commit is contained in:
parent
e341759dfe
commit
4c698d58e0
2 changed files with 16 additions and 2 deletions
|
@ -334,10 +334,11 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()>
|
|||
}
|
||||
}
|
||||
|
||||
let target_is_dir = target.is_dir();
|
||||
let target_is_dir: bool = target.is_dir();
|
||||
let source_is_dir: bool = source.is_dir();
|
||||
|
||||
if path_ends_with_terminator(target)
|
||||
&& !target_is_dir
|
||||
&& (!target_is_dir && !source_is_dir)
|
||||
&& !opts.no_target_dir
|
||||
&& opts.update != UpdateMode::ReplaceIfOlder
|
||||
{
|
||||
|
|
|
@ -1556,6 +1556,19 @@ fn test_mv_dir_into_file_where_both_are_files() {
|
|||
.stderr_contains("mv: cannot stat 'a/': Not a directory");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_dir_into_path_slash() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
at.mkdir("a");
|
||||
scene.ucmd().arg("a").arg("e/").succeeds();
|
||||
assert!(at.dir_exists("e"));
|
||||
at.mkdir("b");
|
||||
at.mkdir("f");
|
||||
scene.ucmd().arg("b").arg("f/").succeeds();
|
||||
assert!(at.dir_exists("f/b"));
|
||||
}
|
||||
|
||||
// Todo:
|
||||
|
||||
// $ at.touch a b
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue