mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 13:07:46 +00:00
Merge pull request #2532 from hbina/hbina-rm-silently-accept-presume-input-tty
Silently accepts ---presume-input-tty
This commit is contained in:
commit
43bdcaf212
2 changed files with 48 additions and 0 deletions
|
@ -50,6 +50,7 @@ static OPT_PROMPT_MORE: &str = "prompt-more";
|
||||||
static OPT_RECURSIVE: &str = "recursive";
|
static OPT_RECURSIVE: &str = "recursive";
|
||||||
static OPT_RECURSIVE_R: &str = "recursive_R";
|
static OPT_RECURSIVE_R: &str = "recursive_R";
|
||||||
static OPT_VERBOSE: &str = "verbose";
|
static OPT_VERBOSE: &str = "verbose";
|
||||||
|
static PRESUME_INPUT_TTY: &str = "presume-input-tty";
|
||||||
|
|
||||||
static ARG_FILES: &str = "files";
|
static ARG_FILES: &str = "files";
|
||||||
|
|
||||||
|
@ -208,6 +209,17 @@ pub fn uu_app() -> App<'static, 'static> {
|
||||||
.long(OPT_VERBOSE)
|
.long(OPT_VERBOSE)
|
||||||
.help("explain what is being done")
|
.help("explain what is being done")
|
||||||
)
|
)
|
||||||
|
// From the GNU source code:
|
||||||
|
// This is solely for testing.
|
||||||
|
// Do not document.
|
||||||
|
// It is relatively difficult to ensure that there is a tty on stdin.
|
||||||
|
// Since rm acts differently depending on that, without this option,
|
||||||
|
// it'd be harder to test the parts of rm that depend on that setting.
|
||||||
|
.arg(
|
||||||
|
Arg::with_name(PRESUME_INPUT_TTY)
|
||||||
|
.long(PRESUME_INPUT_TTY)
|
||||||
|
.hidden(true)
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(ARG_FILES)
|
Arg::with_name(ARG_FILES)
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
|
|
|
@ -314,3 +314,39 @@ fn test_rm_verbose_slash() {
|
||||||
assert!(!at.dir_exists(dir));
|
assert!(!at.dir_exists(dir));
|
||||||
assert!(!at.file_exists(file_a));
|
assert!(!at.file_exists(file_a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rm_silently_accepts_presume_input_tty1() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
let file_1 = "test_rm_silently_accepts_presume_input_tty1";
|
||||||
|
|
||||||
|
at.touch(file_1);
|
||||||
|
|
||||||
|
ucmd.arg("--presume-input-tty").arg(file_1).succeeds();
|
||||||
|
|
||||||
|
assert!(!at.file_exists(file_1));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rm_silently_accepts_presume_input_tty2() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
let file_2 = "test_rm_silently_accepts_presume_input_tty2";
|
||||||
|
|
||||||
|
at.touch(file_2);
|
||||||
|
|
||||||
|
ucmd.arg("---presume-input-tty").arg(file_2).succeeds();
|
||||||
|
|
||||||
|
assert!(!at.file_exists(file_2));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rm_silently_accepts_presume_input_tty3() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
let file_3 = "test_rm_silently_accepts_presume_input_tty3";
|
||||||
|
|
||||||
|
at.touch(file_3);
|
||||||
|
|
||||||
|
ucmd.arg("----presume-input-tty").arg(file_3).succeeds();
|
||||||
|
|
||||||
|
assert!(!at.file_exists(file_3));
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue