mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
rm: do "early return" earlier in uumain
This commit is contained in:
parent
f002c4017f
commit
dfc4e3efe5
1 changed files with 60 additions and 59 deletions
|
@ -119,6 +119,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let force_flag = matches.get_flag(OPT_FORCE);
|
let force_flag = matches.get_flag(OPT_FORCE);
|
||||||
|
|
||||||
|
if files.is_empty() && !force_flag {
|
||||||
|
// Still check by hand and not use clap
|
||||||
|
// Because "rm -f" is a thing
|
||||||
|
return Err(UUsageError::new(1, "missing operand"));
|
||||||
|
}
|
||||||
|
|
||||||
// If -f(--force) is before any -i (or variants) we want prompts else no prompts
|
// If -f(--force) is before any -i (or variants) we want prompts else no prompts
|
||||||
let force_prompt_never: bool = force_flag && {
|
let force_prompt_never: bool = force_flag && {
|
||||||
let force_index = matches.index_of(OPT_FORCE).unwrap_or(0);
|
let force_index = matches.index_of(OPT_FORCE).unwrap_or(0);
|
||||||
|
@ -130,11 +136,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
if files.is_empty() && !force_flag {
|
|
||||||
// Still check by hand and not use clap
|
|
||||||
// Because "rm -f" is a thing
|
|
||||||
return Err(UUsageError::new(1, "missing operand"));
|
|
||||||
} else {
|
|
||||||
let options = Options {
|
let options = Options {
|
||||||
force: force_flag,
|
force: force_flag,
|
||||||
interactive: {
|
interactive: {
|
||||||
|
@ -194,7 +195,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
if remove(&files, &options) {
|
if remove(&files, &options) {
|
||||||
return Err(1.into());
|
return Err(1.into());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue