Skip to content

sysctl: list the variables under a directory key - #831

Merged
sylvestre merged 1 commit into
uutils:mainfrom
qodelicious:sysctl-directory-key
Nov 7, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
qodelicious:sysctl-directory-key

Conversation

@qodelicious

Copy link
Copy Markdown
Contributor

procps-ng sysctl prints every variable under a key that is a directory, like sysctl kernel.random. We only did that with -N, and without it we tried to read the directory and failed with "Is a directory".

Now a directory key is expanded to its variables for every mode, so the normal key = value output and -n both work. The -N path is the same as before. Added a test for kernel.random and -n kernel/random.

Fixes #830

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 38.09524% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.85%. Comparing base (67832aa) to head (b3b3539).
⚠️ Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/sysctl/src/sysctl.rs 0.00% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #831      +/-   ##
==========================================
+ Coverage   19.20%   19.85%   +0.65%     
==========================================
  Files          68       68              
  Lines       10156    10306     +150     
  Branches      546      552       +6     
==========================================
+ Hits         1950     2046      +96     
- Misses       8206     8260      +54     
Flag Coverage Δ
macos_latest 7.01% <ø> (+0.26%) ⬆️
ubuntu_latest 20.21% <38.09%> (+0.66%) ⬆️
windows_latest 0.02% <ø> (-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.

if names {
println!("{}", normalize_var(&var));
} else {
print_one_arg(&var, &matches);

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.

what happens with sysctl vm? vm.drop_caches is write-only, so i guess we print an error and exit 1.
procps-ng skips unreadable keys silently. Could be a follow-up together with -a.

@sylvestre
sylvestre merged commit 93a96df into uutils:main Nov 7, 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: a directory key like kernel.random fails instead of listing its variables

2 participants