From ed35512f8a02d25aa1dae55fc20108f97f53dd1f Mon Sep 17 00:00:00 2001 From: Krysztal Huang Date: Tue, 16 Jul 2024 13:52:46 +0800 Subject: [PATCH] pidof: Implemented `-o` (#123) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * pidof: Implemented `-o` This commit implemented two usage of `-o` which are already implemented in GNU's implementation, but not in ours. ```shell ❯ cargo run pidof zsh 116473 116472 116401 116391 ❯ cargo run pidof -o116473,116472 zsh 116401 116391 ❯ cargo run pidof -o116473 -o116472 zsh 116401 116391 ``` And the GNU's implementation: ```shell ❯ pidof zsh 116473 116472 116401 116391 ❯ pidof -o116473,116472 zsh 116401 116391 ❯ pidof -o116473 -o116472 zsh 116401 116391 ``` * pidof: Add test for `-q` flag. * pidof: Simplify tests. --- src/uu/pidof/src/pidof.rs | 1 + tests/by-util/test_pidof.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/uu/pidof/src/pidof.rs b/src/uu/pidof/src/pidof.rs index e0dbb12..dd71936 100644 --- a/src/uu/pidof/src/pidof.rs +++ b/src/uu/pidof/src/pidof.rs @@ -137,6 +137,7 @@ pub fn uu_app() -> Command { Arg::new("o") .short('o') .help("Omit results with a given PID") + .value_delimiter(',') .action(ArgAction::Append) .value_parser(clap::value_parser!(usize)) .value_name("omitpid"), diff --git a/tests/by-util/test_pidof.rs b/tests/by-util/test_pidof.rs index 4c15eb9..c06c4bc 100644 --- a/tests/by-util/test_pidof.rs +++ b/tests/by-util/test_pidof.rs @@ -33,3 +33,9 @@ fn test_no_program() { fn test_no_pid_found() { new_ucmd!().arg("NO_THIS_PROGRAM").fails().code_is(1); } + +#[test] +#[cfg(target_os = "linux")] +fn test_quiet() { + new_ucmd!().arg("kthreadd").arg("-q").succeeds().no_output(); +}