Skip to content

ps: keep a column for a field that has no value yet - #824

Open
jayhemnani9910 wants to merge 1 commit into
uutils:mainfrom
jayhemnani9910:ps-keep-columns-aligned
Open

jayhemnani9910 wants to merge 1 commit into
uutils:mainfrom
jayhemnani9910:ps-keep-columns-aligned

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

A format field that ps can't fill yet prints its header but no value, so every value after it moves one column to the left:

$ ps -p 1 -l
 F  S  UID  PID  PPID      C        PRI  NI  ADDR  SZ  WCHAN  TTY  TIME  CMD
 0  1  0    ?    00:00:01  systemd
$ ps -p 1 -o stat,pid,comm
 STAT  PID      COMMAND
 1     systemd

The PID shows under S and the command under PID. collect_pickers skipped any code without a picker (stat, nice, pri, wchan, lstart, etimes, ...), while the header kept it. Such a field now prints -, which procps-ng also uses for a value it can't show:

$ ps -p 1 -l
 F  S  UID  PID  PPID  C  PRI  NI  ADDR  SZ  WCHAN  TTY  TIME      CMD
 -  -  0    1    0     -  -    -   -     -   -      ?    00:00:01  systemd

Filling in those fields is separate work; this only keeps the values under the right headers.

Tests: test_unimplemented_field_keeps_columns_aligned fails without the change. cargo test: 225 passed (224 on main); clippy clean.

A format field without a picker (stat, nice, pri, wchan, lstart...)
printed its header but no value, so every later value moved one
column left: ps -l showed the PID under S and the PPID under UID.
Print - for such a field, the mark procps uses for a missing value.
Copilot AI balanced review requested due to automatic review settings October 27, 2026 06:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 19.50%. Comparing base (67832aa) to head (94eb472).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/ps/src/picker.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #824      +/-   ##
==========================================
+ Coverage   19.20%   19.50%   +0.30%     
==========================================
  Files          68       68              
  Lines       10156    10242      +86     
  Branches      546      552       +6     
==========================================
+ Hits         1950     1998      +48     
- Misses       8206     8244      +38     
Flag Coverage Δ
macos_latest 6.75% <0.00%> (ø)
ubuntu_latest 19.86% <93.75%> (+0.31%) ⬆️
windows_latest 0.02% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

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