mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
kill: ignore signal case on -s
This commit is contained in:
parent
524be6e4ae
commit
b617876372
2 changed files with 36 additions and 1 deletions
|
@ -190,7 +190,8 @@ fn list(signals: &Vec<String>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_signal_value(signal_name: &str) -> UResult<usize> {
|
fn parse_signal_value(signal_name: &str) -> UResult<usize> {
|
||||||
let optional_signal_value = signal_by_name_or_value(signal_name);
|
let signal_name_upcase = signal_name.to_uppercase();
|
||||||
|
let optional_signal_value = signal_by_name_or_value(&signal_name_upcase);
|
||||||
match optional_signal_value {
|
match optional_signal_value {
|
||||||
Some(x) => Ok(x),
|
Some(x) => Ok(x),
|
||||||
None => Err(USimpleError::new(
|
None => Err(USimpleError::new(
|
||||||
|
|
|
@ -236,6 +236,17 @@ fn test_kill_with_signal_name_new_form() {
|
||||||
assert_eq!(target.wait_for_signal(), Some(libc::SIGKILL));
|
assert_eq!(target.wait_for_signal(), Some(libc::SIGKILL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_kill_with_signal_name_new_form_ignore_case() {
|
||||||
|
let mut target = Target::new();
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("-s")
|
||||||
|
.arg("KiLl")
|
||||||
|
.arg(format!("{}", target.pid()))
|
||||||
|
.succeeds();
|
||||||
|
assert_eq!(target.wait_for_signal(), Some(libc::SIGKILL));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_kill_with_signal_prefixed_name_new_form() {
|
fn test_kill_with_signal_prefixed_name_new_form() {
|
||||||
let mut target = Target::new();
|
let mut target = Target::new();
|
||||||
|
@ -247,6 +258,29 @@ fn test_kill_with_signal_prefixed_name_new_form() {
|
||||||
assert_eq!(target.wait_for_signal(), Some(libc::SIGKILL));
|
assert_eq!(target.wait_for_signal(), Some(libc::SIGKILL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_kill_with_signal_prefixed_name_new_form_ignore_case() {
|
||||||
|
let mut target = Target::new();
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("-s")
|
||||||
|
.arg("SiGKiLl")
|
||||||
|
.arg(format!("{}", target.pid()))
|
||||||
|
.succeeds();
|
||||||
|
assert_eq!(target.wait_for_signal(), Some(libc::SIGKILL));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_kill_with_signal_name_new_form_unknown_must_match_input_case() {
|
||||||
|
let target = Target::new();
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("-s")
|
||||||
|
.arg("IaMnOtAsIgNaL") // spell-checker:disable-line
|
||||||
|
.arg(format!("{}", target.pid()))
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("unknown signal")
|
||||||
|
.stderr_contains("IaMnOtAsIgNaL"); // spell-checker:disable-line
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_kill_no_pid_provided() {
|
fn test_kill_no_pid_provided() {
|
||||||
// spell-checker:disable-line
|
// spell-checker:disable-line
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue