diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2020-05-04 02:26:17 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-04 09:41:43 +0200 |
commit | f09a8f8a6e8d5c10b4001caeaa9c77732aedc900 (patch) | |
tree | ccc975e373b881051f9f823edec27d3c9e6b956b /Userland | |
parent | e6547a7e95e468463b303bcaeb43fa68e1832382 (diff) | |
download | serenity-f09a8f8a6e8d5c10b4001caeaa9c77732aedc900.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/sysctl.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
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(); } |