1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Merge pull request #2732 from kevinburke/rm-multiple-r

rm: allow -r flag to be specified multiple times
This commit is contained in:
Sylvestre Ledru 2021-10-29 13:30:14 +02:00 committed by GitHub
commit 8fef0c6f31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View file

@ -186,6 +186,7 @@ pub fn uu_app() -> App<'static, 'static> {
)
.arg(
Arg::with_name(OPT_RECURSIVE).short("r")
.multiple(true)
.long(OPT_RECURSIVE)
.help("remove directories and their contents recursively")
)

View file

@ -169,6 +169,29 @@ fn test_rm_recursive() {
assert!(!at.file_exists(file_b));
}
#[test]
fn test_rm_recursive_multiple() {
let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_rm_recursive_directory";
let file_a = "test_rm_recursive_directory/test_rm_recursive_file_a";
let file_b = "test_rm_recursive_directory/test_rm_recursive_file_b";
at.mkdir(dir);
at.touch(file_a);
at.touch(file_b);
ucmd.arg("-r")
.arg("-r")
.arg("-r")
.arg(dir)
.succeeds()
.no_stderr();
assert!(!at.dir_exists(dir));
assert!(!at.file_exists(file_a));
assert!(!at.file_exists(file_b));
}
#[test]
fn test_rm_directory_without_flag() {
let (at, mut ucmd) = at_and_ucmd!();