Skip to content

ps: Refactor process selection + support new flags#559

Merged
cakebaker merged 11 commits intouutils:mainfrom
dezgeg:ps_refact
Nov 3, 2025
Merged

ps: Refactor process selection + support new flags#559
cakebaker merged 11 commits intouutils:mainfrom
dezgeg:ps_refact

Conversation

@dezgeg
Copy link
Contributor

@dezgeg dezgeg commented Nov 2, 2025

Refactor the process selection to better support cases where the behaviour is more complex than simply union of what each individual flag would list. This is bit similar to what is used in pgrep. Also implement new flags that are easier to implement now.

error: implicitly cloning a `String` by calling `to_string` on its dereferenced type
   --> src/uu/pgrep/src/process_matcher.rs:212:8
    |
212 |     Ok(pattern.to_string())
    |        ^^^^^^^^^^^^^^^^^^^ help: consider using: `pattern.clone()`
    |
error: implicitly cloning a `String` by calling `to_string` on its dereferenced type
   --> src/uu/slabtop/src/parse.rs:296:13
    |
296 |             name.to_string(),
    |             ^^^^^^^^^^^^^^^^ help: consider using: `name.clone()`
error: implicitly cloning a `String` by calling `to_string` on its dereferenced type
   --> src/uu/vmstat/src/picker.rs:327:16
    |
327 |     vec![(len, runnable.to_string()), (len, blocked.to_string())]
    |                ^^^^^^^^^^^^^^^^^^^^ help: consider using: `runnable.clone()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#implicit_clone
    = note: `-D clippy::implicit-clone` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::implicit_clone)]`

error: implicitly cloning a `String` by calling `to_string` on its dereferenced type
   --> src/uu/vmstat/src/picker.rs:327:45
    |
327 |     vec![(len, runnable.to_string()), (len, blocked.to_string())]
    |                                             ^^^^^^^^^^^^^^^^^^^ help: consider using: `blocked.clone()`
error: implicitly cloning a `String` by calling `to_string` on its dereferenced type
  --> src/uu/ps/src/mapping.rs:18:39
   |
18 |                 None => (key.clone(), mapping.get(&key).unwrap().to_string()),
   |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `mapping.get(&key).unwrap().clone()`
   |
error: implicitly cloning a `String` by calling `to_string` on its dereferenced type
  --> src/uu/ps/src/ps.rs:97:40
   |
97 |             .map(|code| (code.clone(), default_mapping[&code].to_string()))
   |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `default_mapping[&code].clone()`
@dezgeg dezgeg force-pushed the ps_refact branch 3 times, most recently from ba07bcd to 43c51e1 Compare November 2, 2025 22:57
Refactor the process selection to better support cases where the
behaviour is more complex than simply union of what each individual flag
would list. This is bit similar to what is used in pgrep.
For example, `ps --deselect -A` or `ps --pid` for non existing pid
trigger this.
@cakebaker cakebaker merged commit 9c12e49 into uutils:main Nov 3, 2025
16 checks passed
@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (fc7877d) to head (f1b89bc).
⚠️ Report is 25 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #559   +/-   ##
===========================
===========================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cakebaker
Copy link
Contributor

Thanks, both for the PR and fixing the clippy errors!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments