From 7e577476d81f36cac9f3dd64df924b3761e53b49 Mon Sep 17 00:00:00 2001 From: Smicry Date: Sun, 12 Sep 2021 23:20:05 +0800 Subject: [PATCH 1/4] add kill -l final new line #2644 --- src/uu/kill/src/kill.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/uu/kill/src/kill.rs b/src/uu/kill/src/kill.rs index 494dc0602..b1cbba17a 100644 --- a/src/uu/kill/src/kill.rs +++ b/src/uu/kill/src/kill.rs @@ -160,18 +160,13 @@ fn print_signal(signal_name_or_value: &str) -> UResult<()> { } fn print_signals() { - let mut pos = 0; for (idx, signal) in ALL_SIGNALS.iter().enumerate() { - pos += signal.len(); - print!("{}", signal); - if idx > 0 && pos > 73 { - println!(); - pos = 0; - } else { - pos += 1; + if idx > 0 { print!(" "); } + print!("{}", signal); } + println!(); } fn list(arg: Option) -> UResult<()> { From 7d445612a29a8a2afba61c4024923be13253aca8 Mon Sep 17 00:00:00 2001 From: Smicry Date: Mon, 13 Sep 2021 00:15:53 +0800 Subject: [PATCH 2/4] add kill list final new line test --- tests/by-util/test_kill.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/by-util/test_kill.rs b/tests/by-util/test_kill.rs index fe5d4557a..9afac2862 100644 --- a/tests/by-util/test_kill.rs +++ b/tests/by-util/test_kill.rs @@ -56,6 +56,14 @@ fn test_kill_list_all_signals() { .stdout_contains("HUP"); } +#[test] +fn test_kill_list_final_new_line() { + new_ucmd!() + .arg("-l") + .succeeds() + .stdout_matches(&Regex::new("\\n$").unwrap()); +} + #[test] fn test_kill_list_all_signals_as_table() { // Check for a few signals. Do not try to be comprehensive. From db21fef95de9931a2d0c69cf0ccf3b18966f013d Mon Sep 17 00:00:00 2001 From: Smicry Date: Mon, 13 Sep 2021 09:27:14 +0800 Subject: [PATCH 3/4] fix kill list final new line test --- tests/by-util/test_kill.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_kill.rs b/tests/by-util/test_kill.rs index 9afac2862..a16760689 100644 --- a/tests/by-util/test_kill.rs +++ b/tests/by-util/test_kill.rs @@ -61,7 +61,7 @@ fn test_kill_list_final_new_line() { new_ucmd!() .arg("-l") .succeeds() - .stdout_matches(&Regex::new("\\n$").unwrap()); + .stdout_matches(&Regex::new("[\\n\\r]$").unwrap()); } #[test] From 89428a77f31c26024980be35ed89e4b7de7983d7 Mon Sep 17 00:00:00 2001 From: Smicry Date: Tue, 14 Sep 2021 23:56:08 +0800 Subject: [PATCH 4/4] fix kill list final new line test --- tests/by-util/test_kill.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/by-util/test_kill.rs b/tests/by-util/test_kill.rs index a16760689..91e524733 100644 --- a/tests/by-util/test_kill.rs +++ b/tests/by-util/test_kill.rs @@ -58,10 +58,8 @@ fn test_kill_list_all_signals() { #[test] fn test_kill_list_final_new_line() { - new_ucmd!() - .arg("-l") - .succeeds() - .stdout_matches(&Regex::new("[\\n\\r]$").unwrap()); + let re = Regex::new("\\n$").unwrap(); + assert!(re.is_match(new_ucmd!().arg("-l").succeeds().stdout_str())); } #[test]