mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
uucore+timeout: accept signals of any casing
This commit is contained in:
parent
4183977c93
commit
449c685675
3 changed files with 12 additions and 10 deletions
|
@ -200,8 +200,7 @@ fn list(signals: &Vec<String>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_signal_value(signal_name: &str) -> UResult<usize> {
|
fn parse_signal_value(signal_name: &str) -> UResult<usize> {
|
||||||
let signal_name_upcase = signal_name.to_uppercase();
|
let optional_signal_value = signal_by_name_or_value(signal_name);
|
||||||
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(
|
||||||
|
|
|
@ -340,14 +340,15 @@ pub static ALL_SIGNALS: [&str; 37] = [
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option<usize> {
|
pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option<usize> {
|
||||||
if let Ok(value) = signal_name_or_value.parse() {
|
let signal_name_upcase = signal_name_or_value.to_uppercase();
|
||||||
|
if let Ok(value) = signal_name_upcase.parse() {
|
||||||
if is_signal(value) {
|
if is_signal(value) {
|
||||||
return Some(value);
|
return Some(value);
|
||||||
} else {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let signal_name = signal_name_or_value.trim_start_matches("SIG");
|
let signal_name = signal_name_upcase.trim_start_matches("SIG");
|
||||||
|
|
||||||
ALL_SIGNALS.iter().position(|&s| s == signal_name)
|
ALL_SIGNALS.iter().position(|&s| s == signal_name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,12 +97,14 @@ fn test_preserve_status() {
|
||||||
fn test_preserve_status_even_when_send_signal() {
|
fn test_preserve_status_even_when_send_signal() {
|
||||||
// When sending CONT signal, process doesn't get killed or stopped.
|
// When sending CONT signal, process doesn't get killed or stopped.
|
||||||
// So, expected result is success and code 0.
|
// So, expected result is success and code 0.
|
||||||
|
for cont_spelling in ["CONT", "cOnT", "SIGcont"] {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-s", "CONT", "--preserve-status", ".1", "sleep", "5"])
|
.args(&["-s", cont_spelling, "--preserve-status", ".1", "sleep", "2"])
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.code_is(0)
|
.code_is(0)
|
||||||
.no_stderr()
|
.no_stderr()
|
||||||
.no_stdout();
|
.no_stdout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue