1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

rm: Remove symlinks to directories without -r

Path::is_dir follows symlinks so it returns true for symlinks
to directories. Use symlink_metadata instead so you can remove
symlinks to directories without -r flag.
This commit is contained in:
Shinichiro Hamaji 2017-04-01 23:38:38 +09:00
parent 626a3b7611
commit 4f6841df32
2 changed files with 13 additions and 1 deletions

View file

@ -136,3 +136,15 @@ fn test_rm_verbose() {
ucmd.arg("-v").arg(file_a).arg(file_b).succeeds()
.stdout_only(format!("removed '{}'\nremoved '{}'\n", file_a, file_b));
}
#[test]
fn test_rm_dir_symlink() {
let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_rm_dir_symlink_dir";
let link = "test_rm_dir_symlink_link";
at.mkdir(dir);
at.symlink(dir, link);
ucmd.arg(link).succeeds();
}