mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 14:52:41 +00:00
rm: added new InteractiveMode InteractiveMode::Never
Signed-off-by: Stefin <stefin@pm.me>
This commit is contained in:
parent
9ffb00cd51
commit
a8326d7f3f
1 changed files with 7 additions and 3 deletions
|
@ -29,6 +29,7 @@ enum InteractiveMode {
|
|||
Never,
|
||||
Once,
|
||||
Always,
|
||||
Default,
|
||||
}
|
||||
|
||||
struct Options {
|
||||
|
@ -114,7 +115,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
InteractiveMode::Never
|
||||
InteractiveMode::Default
|
||||
}
|
||||
},
|
||||
one_fs: matches.contains_id(OPT_ONE_FILE_SYSTEM),
|
||||
|
@ -386,7 +387,7 @@ fn remove_file(path: &Path, options: &Options) -> bool {
|
|||
} else {
|
||||
true
|
||||
};
|
||||
if response && prompt_write_protected(path, false) {
|
||||
if response && prompt_write_protected(path, false, options) {
|
||||
match fs::remove_file(path) {
|
||||
Ok(_) => {
|
||||
if options.verbose {
|
||||
|
@ -408,7 +409,10 @@ fn remove_file(path: &Path, options: &Options) -> bool {
|
|||
false
|
||||
}
|
||||
|
||||
fn prompt_write_protected(path: &Path, is_dir: bool) -> bool {
|
||||
fn prompt_write_protected(path: &Path, is_dir: bool, options: &Options) -> bool {
|
||||
if options.interactive == InteractiveMode::Never {
|
||||
return true;
|
||||
}
|
||||
match File::open(path) {
|
||||
Ok(_) => true,
|
||||
Err(err) => {
|
||||
|
|
Loading…
Reference in a new issue