mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #7206 from cakebaker/kill_no_lowercase_signal_names_with_hyphen
kill: don't allow lowercase signal names with '-'
This commit is contained in:
commit
0fd9a293cc
2 changed files with 20 additions and 4 deletions
|
@ -141,6 +141,10 @@ fn handle_obsolete(args: &mut Vec<String>) -> Option<usize> {
|
|||
// Old signal can only be in the first argument position
|
||||
let slice = args[1].as_str();
|
||||
if let Some(signal) = slice.strip_prefix('-') {
|
||||
// With '-', a signal name must start with an uppercase char
|
||||
if signal.chars().next().is_some_and(|c| c.is_lowercase()) {
|
||||
return None;
|
||||
}
|
||||
// Check if it is a valid signal
|
||||
let opt_signal = signal_by_name_or_value(signal);
|
||||
if opt_signal.is_some() {
|
||||
|
|
|
@ -198,12 +198,24 @@ fn test_kill_with_signal_number_old_form() {
|
|||
|
||||
#[test]
|
||||
fn test_kill_with_signal_name_old_form() {
|
||||
for arg in ["-Kill", "-KILL"] {
|
||||
let mut target = Target::new();
|
||||
new_ucmd!()
|
||||
.arg("-KILL")
|
||||
.arg(arg)
|
||||
.arg(format!("{}", target.pid()))
|
||||
.succeeds();
|
||||
assert_eq!(target.wait_for_signal(), Some(libc::SIGKILL));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_kill_with_lower_case_signal_name_old_form() {
|
||||
let target = Target::new();
|
||||
new_ucmd!()
|
||||
.arg("-kill")
|
||||
.arg(format!("{}", target.pid()))
|
||||
.fails()
|
||||
.stderr_contains("unexpected argument");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue