diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2021-06-07 21:20:35 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-08 11:30:58 +0200 |
commit | d7126fbbc2b03d005370ffb8d1195c6d11f11ec9 (patch) | |
tree | 8cc2d96cc33f97aa8fd62b38509402e1a2bd8de9 /Userland/Libraries/LibCore/ArgsParser.cpp | |
parent | 0b0bce78f60c54bd9d91dedc37258a6d75cf5053 (diff) | |
download | serenity-d7126fbbc2b03d005370ffb8d1195c6d11f11ec9.zip |
LibCore/ArgsParser: Learn how to stop on first non-option
We need this for utilities like `env`, that do not gain anything by
parsing the options passed to the command they are supposed to
execute.
Diffstat (limited to 'Userland/Libraries/LibCore/ArgsParser.cpp')
-rw-r--r-- | Userland/Libraries/LibCore/ArgsParser.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp index 5dbec84b7e..c858bea4f0 100644 --- a/Userland/Libraries/LibCore/ArgsParser.cpp +++ b/Userland/Libraries/LibCore/ArgsParser.cpp @@ -42,6 +42,9 @@ bool ArgsParser::parse(int argc, char* const* argv, FailureBehavior failure_beha Vector<option> long_options; StringBuilder short_options_builder; + if (m_stop_on_first_non_option) + short_options_builder.append('+'); + int index_of_found_long_option = -1; // Tell getopt() to reset its internal state, and start scanning from optind = 1. |