From f09a8f8a6e8d5c10b4001caeaa9c77732aedc900 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Mon, 4 May 2020 02:26:17 +0200 Subject: 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. --- Userland/sysctl.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Userland') diff --git a/Userland/sysctl.cpp b/Userland/sysctl.cpp index 5eaa76b5eb..c4647ae354 100644 --- a/Userland/sysctl.cpp +++ b/Userland/sysctl.cpp @@ -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(); } -- cgit v1.2.3