Skip to content

Commit c3a1fdf

Browse files
committed
mv: treat symlinks as files
1 parent 1a7e6c0 commit c3a1fdf

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/uu/mv/src/mv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()>
375375
});
376376
}
377377

378-
let target_is_dir = target.is_dir();
379-
let source_is_dir = source.is_dir();
378+
let target_is_dir = target.is_dir() && !target.is_symlink();
379+
let source_is_dir = source.is_dir() && !source.is_symlink();
380380

381381
if path_ends_with_terminator(target)
382382
&& (!target_is_dir && !source_is_dir)
@@ -415,7 +415,7 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()>
415415
} else {
416416
move_files_into_dir(&[source.to_path_buf()], target, opts)
417417
}
418-
} else if target.exists() && source.is_dir() {
418+
} else if target.exists() && source_is_dir {
419419
match opts.overwrite {
420420
OverwriteMode::NoClobber => return Ok(()),
421421
OverwriteMode::Interactive => {
@@ -747,7 +747,7 @@ fn rename(
747747
}
748748

749749
// "to" may no longer exist if it was backed up
750-
if to.exists() && to.is_dir() {
750+
if to.exists() && to.is_dir() && !to.is_symlink() {
751751
// normalize behavior between *nix and windows
752752
if from.is_dir() {
753753
if is_empty_dir(to) {

0 commit comments

Comments
 (0)