Skip to content

Fixes for option parsing#40641

Merged
yuwata merged 12 commits into
systemd:mainfrom
keszybz:arg-generation-fixes
Feb 13, 2026
Merged

Fixes for option parsing#40641
yuwata merged 12 commits into
systemd:mainfrom
keszybz:arg-generation-fixes

Conversation

@keszybz

@keszybz keszybz commented Feb 11, 2026

Copy link
Copy Markdown
Member

Preparatory work split out of #40624.

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'
Comment thread src/nspawn/nspawn.c
@bluca bluca added good-to-merge/with-minor-suggestions and removed please-review PR is ready for (re-)review by a maintainer labels Feb 12, 2026
Comment thread src/nspawn/nspawn.c
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.
@keszybz keszybz added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed good-to-merge/with-minor-suggestions labels Feb 13, 2026
@yuwata yuwata merged commit da86da2 into systemd:main Feb 13, 2026
50 of 55 checks passed
@github-actions github-actions Bot removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Feb 13, 2026
@keszybz keszybz deleted the arg-generation-fixes branch February 16, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants