Skip to content

Commit

Permalink
sysctl: Permit 'sysctl -a' invocation
Browse files Browse the repository at this point in the history
The point of '-a' is to list all keys.
It is counter-intuitive to require the user to then
supply a specific key additionally.
  • Loading branch information
BenWiederhake authored and awesomekling committed May 4, 2020
1 parent e6547a7 commit f09a8f8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Userland/sysctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ int main(int argc, char** argv)

Core::ArgsParser args_parser;
args_parser.add_option(show_all, "Show all variables", nullptr, 'a');
args_parser.add_positional_argument(var, "Command (var[=value])", "command");
args_parser.add_positional_argument(var, "Command (var[=value])", "command", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv);

if (var == nullptr) {
// Not supplied; assume `-a`.
show_all = true;
}

if (show_all) {
// Ignore `var`, even if it was supplied. Just like the real procps does.
return handle_show_all();
}

Expand Down

0 comments on commit f09a8f8

Please sign in to comment.