mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
rm: exit normally when -f is used with no operand
This commit is contained in:
parent
be5ce3c252
commit
a1cf262414
2 changed files with 20 additions and 2 deletions
|
@ -66,6 +66,9 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
Ok(m) => m,
|
||||
Err(f) => crash!(1, "{}", f)
|
||||
};
|
||||
|
||||
let force = matches.opt_present("force");
|
||||
|
||||
if matches.opt_present("help") {
|
||||
println!("{} {}", NAME, VERSION);
|
||||
println!("");
|
||||
|
@ -87,13 +90,13 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
println!("assurance that the contents are truly unrecoverable, consider using shred.");
|
||||
} else if matches.opt_present("version") {
|
||||
println!("{} {}", NAME, VERSION);
|
||||
} else if matches.free.is_empty() {
|
||||
} else if matches.free.is_empty() && !force {
|
||||
show_error!("missing an argument");
|
||||
show_error!("for help, try '{0} --help'", NAME);
|
||||
return 1;
|
||||
} else {
|
||||
let options = Options {
|
||||
force: matches.opt_present("force"),
|
||||
force: force,
|
||||
interactive: {
|
||||
if matches.opt_present("i") {
|
||||
InteractiveMode::InteractiveAlways
|
||||
|
|
|
@ -158,3 +158,18 @@ fn test_rm_invalid_symlink() {
|
|||
|
||||
ucmd.arg(link).succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rm_force_no_operand() {
|
||||
let mut ucmd = new_ucmd!();
|
||||
|
||||
ucmd.arg("-f").succeeds().no_stderr();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rm_no_operand() {
|
||||
let mut ucmd = new_ucmd!();
|
||||
|
||||
ucmd.fails()
|
||||
.stderr_is("rm: error: missing an argument\nrm: error: for help, try 'rm --help'\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue