sysctl: Permit 'sysctl -a' invocation

The point of '-a' is to list all keys.
It is counter-intuitive to require the user to then
supply a specific key additionally.
This commit is contained in:
Ben Wiederhake 2020-05-04 02:26:17 +02:00 committed by Andreas Kling
parent e6547a7e95
commit f09a8f8a6e
Notes: sideshowbarker 2024-07-19 07:00:03 +09:00

View file

@ -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();
}