mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
rm: allow -r flag to be specified multiple times
GNU rm allows the `-r` flag to be specified multiple times, but uutils/coreutils would previously exit with an error. I encountered this while attempting to run `make clean` on the Postgres source tree (github.com/postgres/postgres). Updates #1663.
This commit is contained in:
parent
1b39a10938
commit
3e1c5c2d99
2 changed files with 24 additions and 0 deletions
|
@ -186,6 +186,7 @@ pub fn uu_app() -> App<'static, 'static> {
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(OPT_RECURSIVE).short("r")
|
Arg::with_name(OPT_RECURSIVE).short("r")
|
||||||
|
.multiple(true)
|
||||||
.long(OPT_RECURSIVE)
|
.long(OPT_RECURSIVE)
|
||||||
.help("remove directories and their contents recursively")
|
.help("remove directories and their contents recursively")
|
||||||
)
|
)
|
||||||
|
|
|
@ -169,6 +169,29 @@ fn test_rm_recursive() {
|
||||||
assert!(!at.file_exists(file_b));
|
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]
|
#[test]
|
||||||
fn test_rm_directory_without_flag() {
|
fn test_rm_directory_without_flag() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue