mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #1116 from Arcterus/rm_f_fix
rm: exit normally when -f is used with no operand
This commit is contained in:
+5
-2
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user