Skip to content

ps: leave out the header line when every header is empty - #822

Merged
sylvestre merged 2 commits into
uutils:mainfrom
jayhemnani9910:ps-no-header-when-all-empty
Nov 15, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
jayhemnani9910:ps-no-header-when-all-empty

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

ps -o pid= blanks the header, but the header row is still printed, made of spaces:

$ ps -o pid= -p 1 | od -c
0000000          \n       1      \n
0000007
$ /usr/bin/ps -o pid= -p 1     # procps-ng 4.0.4
      1

So ps -o pid= -p "$pid" | head -1, or a read of the first line, gets an empty line. The procps-ng man page: "If all column headers are empty (ps -o pid= -o comm=) then the header line will not be output." uumain now skips the header row when every mapped header is empty. One named header (-o pid=,ppid) still prints the header line, as in procps-ng. The column padding is unchanged; that is a separate difference.

Tests: test_all_empty_headers_print_no_header_line (-o pid=, -o pid= -o ppid=, and -o pid=,ppid keeping its header) fails without the change. cargo test --workspace: 225 passed in the main test binary (224 on main), the others unchanged; clippy shows the same 7 warnings as main.

ps -o pid= still printed a header row made of spaces, so the first line
of output was blank. procps-ng, as its man page says, prints no header
line when all column headers are empty.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 11:47

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 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.21%. Comparing base (67832aa) to head (cf68181).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/ps/src/ps.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #822      +/-   ##
==========================================
+ Coverage   19.20%   20.21%   +1.01%     
==========================================
  Files          68       68              
  Lines       10156    10100      -56     
  Branches      546      552       +6     
==========================================
+ Hits         1950     2042      +92     
+ Misses       8206     8058     -148     
Flag Coverage Δ
macos_latest 7.12% <0.00%> (+0.37%) ⬆️
ubuntu_latest 20.59% <87.50%> (+1.04%) ⬆️
windows_latest 0.02% <0.00%> (+<0.01%) ⬆️

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.

Comment thread tests/by-util/test_ps.rs
.succeeds()
.stdout_matches(&Regex::new(r"\A *1 +0 *\n\z").unwrap());

// One named header keeps the header line.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are you sure procps-ng splits pid=,ppid? i think it takes ",ppid" as the pid header
could you please use -o pid= -o ppid here instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to -o pid= -o ppid in cf68181.

For what it's worth, procps-ng 4.0.4 does split it here; both forms print the same:

$ ps --version
ps from procps-ng 4.0.4
$ ps -o pid=,ppid -p $$
           PPID
1256032   38897
$ ps -o pid= -o ppid -p $$
           PPID
1256032   38897

Copilot AI balanced review requested due to automatic review settings November 15, 2026 04:56

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. Try requesting a review at a lower effort level.

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.

@sylvestre
sylvestre merged commit dec233c into uutils:main Nov 15, 2026
18 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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.

3 participants