Fixes for option parsing#40641
Merged
Merged
Conversation
When we say '-n --iterations=N' in --help, this means that the program can be invoked with '-n N' or '--iterations=N' or '--iterations N'. (The short option is specified without the argument.) Here we tried to use '-p --order=path' to mean that the program can be invoked with '-p' or '--order=path', but that is incompatible with the established convention. Also, indicate that the arg to --cpu is optional.
See parent commit for explanation.
See grandparent commit for explanation.
No functional change, just less indents.
The line to set opterr=0 was added in the initial commit in 3d090cc. But afaict, this never worked as intended, because ':' must be the first char in optstring given to getopt_long() for it to return ':' for a missing option value. Since this wasn't set, getopt_long() would return '?', and the missing value would be handled as an unknown option: $ build/systemd-journal-upload --key Unknown option --key. $ build/systemd-journal-upload --asdf Unknown option --asdf. Let's just do the standard thing: $ build/systemd-journal-upload --key build/systemd-journal-upload: option '--key' requires an argument $ build/systemd-journal-upload --asdf build/systemd-journal-upload: unrecognized option '--asdf'
8004251 to
8739760
Compare
bluca
approved these changes
Feb 12, 2026
yuwata
approved these changes
Feb 13, 2026
This is just to make parse_argv() slightly more managable.
No functional change, just splitting up of a lengthy function.
The two options are were not documented or ever used in the codebase. Additionally, the parser expected an argumentless option, while the option table declared a required argument. So I think this was added for debugging and never excercised properly. Since there was no public documentation for those, it's as if they never existed, so it should be fine to drop them.
Just like in the --help strings, we need to avoid confusion between short options which take an argument and those that don't.
8739760 to
c46cc26
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preparatory work split out of #40624.