Skip to content

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

Open
jayhemnani9910 wants to merge 1 commit into
uutils:mainfrom
jayhemnani9910:ps-no-header-when-all-empty
Open

jayhemnani9910 wants to merge 1 commit 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 19.49%. Comparing base (67832aa) to head (8d8e1e5).
⚠️ Report is 16 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%   19.49%   +0.29%     
==========================================
  Files          68       68              
  Lines       10156    10242      +86     
  Branches      546      552       +6     
==========================================
+ Hits         1950     1997      +47     
- Misses       8206     8245      +39     
Flag Coverage Δ
macos_latest 6.74% <0.00%> (-0.01%) ⬇️
ubuntu_latest 19.85% <87.50%> (+0.30%) ⬆️
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.

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