mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Command-line arguments: be better at detecting absent optional args.
Previously, "--list-fingerprint --quiet" was an error. Now, the handler for optional arguments to "--list-fingerprint" can tell that "--quiet" is a flag, not an argument. This only affects flags that take an _optional_ argument, so you can still put your torrc file in a location starting with "-". Closes #40223.
This commit is contained in:
parent
b50fcdc2e7
commit
558aaf1c32
5
changes/argument_parse
Normal file
5
changes/argument_parse
Normal file
@ -0,0 +1,5 @@
|
||||
o Minor features (command-line interface):
|
||||
- When parsing command-line flags that take an optional argument,
|
||||
treat the argument as absent if it would start with a '-' character.
|
||||
Arguments in that form are not intelligible for any of our
|
||||
optional-argument flags. Closes ticket 40223.
|
@ -2601,8 +2601,11 @@ config_parse_commandline(int argc, char **argv, int ignore_errors)
|
||||
parsed_cmdline_free(result);
|
||||
return NULL;
|
||||
}
|
||||
} else if (want_arg == ARGUMENT_OPTIONAL && is_last) {
|
||||
} else if (want_arg == ARGUMENT_OPTIONAL &&
|
||||
/* optional arguments may never start with '-'. */
|
||||
(is_last || argv[i+1][0] == '-')) {
|
||||
arg = tor_strdup("");
|
||||
want_arg = ARGUMENT_NONE; // prevent skipping the next flag.
|
||||
} else {
|
||||
arg = (want_arg != ARGUMENT_NONE) ? tor_strdup(argv[i+1]) :
|
||||
tor_strdup("");
|
||||
|
Loading…
Reference in New Issue
Block a user