diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 855afcc1f..19a7c274f 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -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 { diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index 4b923767b..175b91e7d 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -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