From 02cc67c915332fa488d69ea63e75a8bf1af9fa07 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 3 Apr 2022 00:35:35 +0200 Subject: [PATCH] rm: rename none by --interactive=never to fix ../gnu/tests/rm/i-never.sh --- src/uu/rm/src/rm.rs | 6 +++--- tests/by-util/test_rm.rs | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index a1924b41d..0701387d9 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -24,7 +24,7 @@ use walkdir::{DirEntry, WalkDir}; #[derive(Eq, PartialEq, Clone, Copy)] enum InteractiveMode { - None, + Never, Once, Always, } @@ -101,7 +101,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { InteractiveMode::Once } else if matches.is_present(OPT_INTERACTIVE) { match matches.value_of(OPT_INTERACTIVE).unwrap() { - "none" => InteractiveMode::None, + "never" => InteractiveMode::Never, "once" => InteractiveMode::Once, "always" => InteractiveMode::Always, val => { @@ -112,7 +112,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } } else { - InteractiveMode::None + InteractiveMode::Never } }, one_fs: matches.is_present(OPT_ONE_FILE_SYSTEM), diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index f813f071c..1b45175a8 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -326,3 +326,24 @@ fn test_rm_silently_accepts_presume_input_tty2() { assert!(!at.file_exists(file_2)); } + +#[test] +fn test_rm_interactive_never() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + let file_2 = "test_rm_interactive"; + + at.touch(file_2); + #[cfg(feature = "chmod")] + scene.ccmd("chmod").arg("0").arg(file_2).succeeds(); + + scene + .ucmd() + .arg("--interactive=never") + .arg(file_2) + .succeeds() + .stdout_is(""); + + assert!(!at.file_exists(file_2)); +}