Skip to content

sysctl: treat -o and -x as flags that take no value - #837

Merged
sylvestre merged 1 commit into
uutils:mainfrom
emirmrkaljevic:sysctl-noop-flags
Nov 10, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
emirmrkaljevic:sysctl-noop-flags

Conversation

@emirmrkaljevic

Copy link
Copy Markdown
Contributor

Fixes #835.

procps-ng documents -o and -x as no-ops for BSD compatibility. They do not take a value, so sysctl -o kernel.ostype should print the key. On main, clap treated both as options with a value, which swallowed the operand and printed help instead. sysctl -o -n kernel.ostype failed with a value is required for '-o <noop_o>'.

I set ArgAction::SetTrue on both flags, which also drops the <noop_o> / <noop_x> placeholders from --help. sysctl -ox kernel.ostype already worked and is covered by the new test.

I found the mismatch with behave, against GNU procps-ng 4.0.4.

cargo test -j 1 --no-default-features --features sysctl,pmap --test tests, cargo fmt --check, and cargo clippy -j 1 --no-default-features --features sysctl,pmap --all-targets -- -D warnings pass. I skipped the default feature set because uu_top needs libsystemd, which is not installed on this machine.

procps-ng documents -o and -x as no-ops for BSD compatibility. They
must not consume the next operand, so sysctl -o kernel.ostype prints
the key instead of treating the key as an argument to -o.
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
src/uu/sysctl/src/sysctl.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #837      +/-   ##
==========================================
+ Coverage   19.20%   20.11%   +0.91%     
==========================================
  Files          68       68              
  Lines       10156    10343     +187     
  Branches      546      552       +6     
==========================================
+ Hits         1950     2081     +131     
- Misses       8206     8262      +56     
Flag Coverage Δ
macos_latest 7.01% <0.00%> (+0.26%) ⬆️
ubuntu_latest 20.49% <90.00%> (+0.93%) ⬆️
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.

@sylvestre
sylvestre merged commit 32e1518 into uutils:main Nov 10, 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.

sysctl: -o and -x consume the next operand instead of being no-op flags

2 participants